开发者

What is the difference between render :object and :collection?

开发者 https://www.devze.com 2023-01-21 05:36 出处:网络
Is it @cart have to put in :obj开发者_如何学JAVAect ? @cart.item have to put in : collection ? Using :collection will run the partial once for every item in the array.While you\'re in the partial, t

Is it


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

0

精彩评论

暂无评论...
验证码 换一张
取 消