2012-04-20 8 views
0

私は選択した値をマイコンに値として渡したい:quantity。私は何を間違っているのですか?select_tagから渡した値

<%= label(:ammount, "Ammount:") %> 
<%= select_tag(:ammount, options_for_select([1,2,3,4,5,6,7,8,9,10])) %> 

<%= button_to 'Add to cart', line_items_path(:product_id => product.id, :quantity => :ammount) %> 

答えて

2

あなたは行動をcontroller`sためにデータを渡すために、こちらのフォームを使用する必要があります。

<%= form_tag line_items_path(:product_id => product.id) do %> 
    <%= label(:ammount, "Ammount:") %> 
    <%= select_tag(:ammount, options_for_select([1,2,3,4,5,6,7,8,9,10])) %> 
    <%= submit_tag 'Add to cart' %> 
<% end %> 

あなただけの量としてcontroller`sアクションにシンボル:ammountを通過している、あなたのソースで行ったすべてのことparam。

+0

ありがとうございました!この問題が修正されました! ;) –