Rails使用一个表单标记进行多个操作

时间:2017-11-25 05:40:25

标签: ruby-on-rails

我正在严格寻找铁路的答案,并希望能够很好地解释它是如何工作的,因为我已经尝试了几个小时但无法弄明白。

我要做的是拥有一个select_tag但能够将参数:number_of_cards传递给多个动作(无论动作是在同一个控制器中还是在不同的控制器中都无关紧要。)

示例代码

<%= form_tag arbitrary_1st_path, :method => :get do |f| %>
  <%= select_tag(:number_of_cards, options_for_select(1..20, 2)) %>
  <%= submit_tag("1st_path")%>
<% end %>
<%= form_tag arbitrary_2nd_path, :method => :get do |f| %>
  <%= select_tag(:number_of_cards, options_for_select(1..20, 2)) %>
  <%= submit_tag("2nd_path")%>
<% end %>
<%= form_tag arbitrary_3rd_path, :method => :get do |f| %>
  <%= select_tag(:number_of_cards, options_for_select(1..20, 2)) %>
  <%= submit_tag("3rd_path")%>
<% end %>

提前感谢!

0 个答案:

没有答案