我想复制这个:
<a href="thepledge.html" class="btn btn-inverse btn-mini btn-ten"><i class="icon-pencil"></i>Take The Pledge</a>
我试过这个:
<%= link_to("Take the pledge", root_path, :class => "btn btn-inverse btn-mini btn-ten") do %>
<i class="icon-pencil"></i>
<% end %>
但它给了我这个错误:
NoMethodError at /
undefined method `stringify_keys' for "/":String
在 link_to
调用中。
想法?
最佳答案
根据documentation您需要将(完整的)链接文本放在 block 中,如下所示:
<%= link_to(root_path, :class => "btn btn-inverse btn-mini btn-ten") do %>
<i class="icon-pencil">Take the pledge</i>
<% end %>
关于ruby-on-rails - 如何在 link_to 帮助器中添加 <i> 标签?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14062632/