I get the following error:
ActionView::TemplateError (You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.include?) on line
21: <% @achievements.each do |achievement| %>
22: <%= achievement.name %>
23: <%= achievement.level %>
24: by <%= achievement.user.username %><br/>
25: <% end %>
The strange thing is that when the index page loads for the first time, then there is no problem. When I update, I get the error above.
The controller is as follows:
class IndexController < ApplicationController
def index
@achievements = Achievement.find(:all)
end
end
Does this have anything to do with caching? Or is it too much memory? If so, can I load the username differently? I'm confused!
source
share