Model Item belongs_to User.
In my controller I have code like this:
@items = Item.find(:all)
I need to have a corresponding User models for each item in my View templates.
it works in controller(but not in View template):
@items.each { |item| item.user }
But manual looping just to build associations for View template kinda smells.
How can I do this not in a creepy way?
Use the :include option for find:
Be sure to read the eager loading section under associations so you’re not doing a bunch of database lookups when they can be combined.