Parameters of partial renders, ROR3
I have this hack to make the partial render work, because the partial render only works with the instance variable @product. I'm pretty su开发者_JS百科re it's not the best way to work this out, can someone please point a better way?
<% products.each do |product| %>
<% @product=product %>
<%= render 'cart_form', :product => @product %>
You might want to render a collection here without using the .each loop. Take a look at the RailsGuides and try something like this:
<%= render :partial => "cart_form", :collection => @products %>
(and set @products in your controller)
精彩评论