Html Rails-带有自定义控制器路径和css类以及确认的删除按钮

Html Rails-带有自定义控制器路径和css类以及确认的删除按钮,html,ruby-on-rails,ruby,haml,Html,Ruby On Rails,Ruby,Haml,到目前为止,我得到的是: = button_to 'Delete', "/blog/#{@post.id}", method: 'delete', class: 'btn btn-danger' 但是,添加一个确认:“您确定吗”无效。而且那行很难看,我想把它缩短。 <%= button_to 'Delete', blog(@post), method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-dan

到目前为止,我得到的是:

= button_to 'Delete', "/blog/#{@post.id}", method: 'delete', class: 'btn btn-danger'
但是,添加一个
确认:“您确定吗”
无效。而且那行很难看,我想把它缩短。


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

我正在使用rails v4.1.8。安东尼的解决方案对我不起作用。 我需要稍微修改一下语法:

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

我正在使用rails v4.1.8。安东尼的解决方案对我不起作用。 我需要稍微修改一下语法:

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


按钮\u to
似乎最多只接受3个参数。我在这里数4。或者我错了
按钮\u to
似乎最多只接受3个参数。我在这里数4。还是我错了