尽管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>
有什么主意吗?