On 3 September 2017 at 03:33, Ben Edwards <login@funkytwig.com> wrote:
> Just noticed and error in the view, should of been
>
> <% @current_events.each do |ce| %>
>
> Now getting a different error:
>
> undefined method `each' for nil:NilClass
That is saying that you have tried to all each on an object that is
nil, so that means @current_events is nil, which is not surprising as
you have not set it anywhere. You need to setup @current_events to the
events you want to show in index method of the controller. So
something like
def index
@current_events = CurrentEvent.all
end
Colin
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLsPtA_jmL%3DA_G%2BK18aymft3U_xdpoZL9u3b7Md3WLz3vg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment