Rails - 删除按钮与自定义控制器路径和 CSS 类以及确认

Kil*_*yte 0 html ruby haml ruby-on-rails

到目前为止我得到了什么:

= button_to 'Delete', "/blog/#{@post.id}", method: 'delete', class: 'btn btn-danger'
Run Code Online (Sandbox Code Playgroud)

但是添加 aconfirm: 'Are you sure'没有效果。而且那条线非常难看,我想缩短它。

Ant*_*ony 5

    <%= button_to 'Delete', blog(@post), method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-danger' %>
Run Code Online (Sandbox Code Playgroud)