如何在同一个表单上有多个 submit_tag 按钮?现在我只为一个按钮工作,但我不确定如何让 form_tag 处理多个路径。
路由.rb
resources :actions do
end
root 'home#start'
match '/home/add', to: 'home#add', via: 'get'
match '/home/subtract', to: 'home#subtract', via: 'get'
match '/home/multiply', to: 'home#multiply', via: 'get'
开始.html.erb
<%= form_tag "/home/add",:method => "get" do %>
<p></p>
<p>
<%= label_tag :entered, "Please enter value:" %> </br>
<%= text_field_tag :entered %>
</p>
<p></p>
<p>
<%= label_tag :entered2, "Please enter value:" %> </br>
<%= text_field_tag :entered2 %>
</p>
<%= submit_tag "add", :controller => "home", :action => "add" %>
<%= submit_tag "subtract", :controller => "home", :action => "subtract" %>
<%= submit_tag "multiply", :controller => "home", :action => "multiply"%>
<% end %>
请指教。先感谢您。