Hi,
Absolute Rails beginner here.
in app/views/players/show.html.rb:
<%= render :partial => @player.items %>
in app/views/items/_item.html.erb
<ul> <% div_for item do %> <li> <%= h(item.name) %> </li> <% end %> </ul>
That works fine. I'm trying to get rid of the partial, so I do something like:
in app/views/players/show.html.rb
<ul> <% div_for @player.items do %> <li> <%= h(item.name) %> </li> <% end %> </ul>
That doesn't work with error "undefined local variable or method `item'"
How do I iterate over the items?
From script/console:
player.items
=> [#<Item id: 4, name: "Chopsticks", quantity: nil, player_id: 2, created_at: "2009-03-18 16:39:42", updated_at: "2009-03-18 16:39:42">, #<Item id: 5, name: "Bowl", quantity: nil, player_id: 2, created_at: "2009-03-18 17:04:12", updated_at: "2009-03-18 17:04:12">]