为什么button_to方法未设置为删除?

时间:2019-01-17 15:54:03

标签: ruby-on-rails ruby-on-rails-4

尽管button_to的文档很简单,但我得到的方法是post而不是delete

这是我的实现方式:

= button_to experiment_path(experiment), params: {tr_number: tr_counter}, remote: true, form: { "data-type" => "script"}, data: { confirm: "Are you sure?" }, :style=>"padding: 3px;", :class=>'btn btn-danger', :method => :delete do
    %i{class: 'fa fa-trash'}

结果是:

<form data-type="script" class="button_to" method="post" action="/en/experiments/10170-dc-voltage-inverter-using-capacitor" data-remote="true">
  <input type="hidden" name="_method" value="delete">
  <button data-confirm="Are you sure?" style="padding: 3px;" class="btn btn-danger" type="submit">
    <i class="fa fa-trash"></i>
  </button>
  <input type="hidden" name="authenticity_token" value="xxxxx">
  <input type="hidden" name="tr_number" value="0">
</form>

有什么主意吗?

0 个答案:

没有答案