如何在rails 3中将buttonstrap图标添加到button_to

时间:2012-07-13 04:57:08

标签: ruby-on-rails ruby-on-rails-3 twitter-bootstrap

我的原始代码是

<%= button_to 'Destroy', girl, confirm: 'Are you sure?', :disable_with => 'deleting...', method: :delete, :class => 'btn-mini btn-danger btn'  %>

我想在“Destroy”这个词前添加一个图标。

icon标签就是这个

<i class="icon-pencil icon-white"></i>

我该怎么做?

1 个答案:

答案 0 :(得分:9)

尝试使用块

<%= link_to girl, confirm: 'Are you sure?', disable_with: 'deleting...', method: :delete, class: 'btn-mini btn-danger btn' do %>
  <i class="icon-pencil icon-white"></i> Destroy
<% end %>

http://apidock.com/rails/v3.2.1/ActionView/Helpers/UrlHelper/button_to

http://apidock.com/rails/v3.2.1/ActionView/Helpers/UrlHelper/link_to