我想复制一下:
<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
来电。
思考?
答案 0 :(得分:5)
根据documentation,您需要将(完整)链接文本放在块中,如下所示:
<%= link_to(root_path, :class => "btn btn-inverse btn-mini btn-ten") do %>
<i class="icon-pencil">Take the pledge</i>
<% end %>
答案 1 :(得分:2)
<%= link_to(root_path, :class => "btn btn-inverse btn-mini btn-ten") do %>
<i class="icon-pencil"></i>
Take The Pledge
<% end %>