我想添加有趣的图标
<i class="fa fa-trash-o"></i>
代替"Destroy“
<%= link_to 'Destroy', post_path(post), method: :delete, data: { confirm: 'Are you sure?' } %>
发布于 2013-11-15 10:01:54
你可以试试
<%= link_to(
content_tag(
:i,
nil,
class: 'fa fa-trash-o'
),
method: :delete,
data: {
confirm: 'Are you sure?'
}
)
%>
你可以尝试其他不是:i
的东西,比如:div
,如果你想在里面使用文本,比如<i>TEXT</i>
,你可以尝试使用文本而不是nil,希望这能对你有所帮助。
发布于 2018-05-31 17:46:36
你也可以像这样使用一个块
<%= link_to post_path(post), method: :delete, data: { confirm: 'Are you sure?' } do %>
<i class="fa fa-trash-o"></i>
<% end %>
https://stackoverflow.com/questions/19985836
复制相似问题