Forum: Ruby on Rails NoMethodError after refresh?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
E1d5e18df7b602c1673672d3e4583ce7?d=identicon&s=25 Michael Evans (magic6435)
on 2008-11-14 18:02
(Received via mailing list)
This is strange. I'm working on a simple comment system but it has a
fit when displaying the user names after the first time the page is
loaded. so if i start the webserver then go to the page everything
works fine but if i then refresh i get this error. if i remove the
user.login it works fine always. Also i have other places in the site
that show the Mode.user.login and they work fine

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 #12 of app/
11:   <% @bid.comments.each do |comment| %>
12:     <%= comment.user.login %>
13:     <%= simple_format(comment.comment) %>
14:   <% end %>

Any one got an idea of why this is happening? if i set the dev env to
cache classes then it has no problems..
config.cache_classes = true

Thanks for any help.
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2008-11-14 18:42
(Received via mailing list)
Typically this means you have confused rails' dependency system. One
way you can achieve that is using require to load your application
classes instead of require_dependency. I wrote a blog post about that
not too long ago. You should be able to find it if you google for
"required or not"


Sent from my iPhone

On 14 Nov 2008, at 17:01, "" <>
E1d5e18df7b602c1673672d3e4583ce7?d=identicon&s=25 Michael Evans (magic6435)
on 2008-11-15 16:58
(Received via mailing list)
Ah thanks ill give that a try.

On Nov 14, 12:41 pm, Frederick Cheung <>
This topic is locked and can not be replied to.