-2

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

<% 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 %>

错误是:

“javascript:void(0)”的未定义方法“stringify_keys”:字符串

4

1 回答 1

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 种形式)

于 2013-07-04T18:26:51.003 回答