在ruby link_to中添加span

时间:2013-07-04 18:21:05

标签: ruby-on-rails

我收到这段代码的错误。谁能明白为什么?

<% link_to("#{(current_user.acting_as == "Participant") ? t(:uploaded_by_host) : t(:uploaded_by_you)}", "javascript:void(0)", :class => "button button-mini button-blue") do %>
<span class="icon icon-plus-sign"></span>
<% end %>

错误是:

  

未定义的方法`stringify_keys'表示“javascript:void(0)”:String

1 个答案:

答案 0 :(得分:3)

您无法将一个块传递给link_to 将链接文本作为参数传递给它。它也没有意义。修改您的代码:

<%= link_to("javascript:void(0)", :class => "button button-mini button-blue") do %>
  <span class="icon icon-plus-sign"></span> <%= current_user.acting_as == "Participant" ? t(:uploaded_by_host) : t(:uploaded_by_you) %>
<% end %>

请参阅:http://apidock.com/rails/ActionView/Helpers/UrlHelper/link_to(您在此处使用第4个表单)