2011-08-01 218 views
0

我無法整理表格。我正在學習教程(使用Rails進行敏捷Web開發),並試圖簡單地將字段Quantity添加到我的line_items表中。無法弄清楚這一點。請幫忙。我怎樣才能改變button_to來傳遞額外的價值?如果 Ruby on Rails中的表格

<%通知書%>

<p id="notice" ><%= notice %></p> 
<% end %> 
<h1>Your Pragmatic Catalog</h1> 
<% @products.each do |product| %> 
<div class="entry" > 
<%= image_tag(product.image_url) %> 
<h3><%= product.title %></h3> 
<%=sanitize product.description %> 
<div class="price_line" > 
<span class="price" ></span> 
<%= button_to 'Add to Cart', line_items_path(:product_id => product) %> 
</div> 
</div> 

<%結束%>

+0

您負責的模型是否已將此屬性添加到它?任何時候我遇到過這個問題都是因爲我忘了將屬性添加到模型中。 –

回答

0

,你可以這樣做:

<%= button_to 'Add to Cart', { :action => "delete", :id => @image.id, :locals => {:quantity => quantity} } %>