开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜