Rails 如何把 select 选择的值通过 button_to 传输给另外的一个 controller 中的 action?

zafu10 · April 27, 2012 · Last by ericguo replied at June 29, 2012 · 4773 hits

<%= 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 %>

希望实现上面代码类似的功能,但是我想要传输的是 ammout 的值给另一个 controller,类似于

<%= button_to 'Add to cart', line_items_path( :quantity => :ammount) %> 该如何实现呢?

貌似不可以,button_to 实际上是封装了 form_tag 的 link_to,所以还是 在 form tag 里面老老实实用 hidden field 吧…

You need to Sign in before reply, if you don't have an account, please Sign up first.