【发布时间】:2017-02-10 02:02:19
【问题描述】:
我的edit 视图中有一个form_tag:
<%= form_tag stage_batch_path(@stage_batch), multipart: true, class: 'form-inline', role: 'form', method: :put do %>
<div class="form-group">
<%= label_tag 'csv_batch_file', 'Select batch file' %>
<%= file_field_tag 'csv_batch_file', class: 'form-control' %>
</div>
<br>
<div class="form-group">
<%= label_tag 'potential_item_id', 'Input item id' %>
<%= text_field_tag "potential_item_id" %>
</div>
<br>
<%= button_tag 'Stage', class: 'btn btn-primary' %>
<% end %>
目前 puts 到 stage_batches/:id 这是我想要的。
但是,我想将posts 的另一个按钮添加到其他控制器,例如Foo#create。我在another answer 中读到formaction 选项将起作用。但是给定的示例使用form_for 而不是form_tag:
<% form_for(something) do |f| %>
...
<%= f.submit "Create" %>
<%= f.submit "Special Action", formaction: special_action_path %>
<% end %>
如何将我的form_tag 重写为form_for?
【问题讨论】:
标签: ruby-on-rails forms ruby-on-rails-4