views:

17

answers:

1

is it @cart have to put in :object ? @cart.item have to put in : collection ?

+3  A: 

Using :collection will run the partial once for every item in the array. While you're in the partial, the name of the object will be the name of the partial. So if you have:

<%= render :partial => 'cart', :collection => @carts %>

Then in your partial (_cart.html.erb, for example) you can use the cart object:

Cart Name: <%= cart.name %>

Here's a link to the documentation:

http://guides.rubyonrails.org/layouts_and_rendering.html

Jaime Bellmyer