我正在尝试使用html传递link_to块但无法获取它.我尝试了一些没有运气的方法,所以我将使用我的原始代码:
<% link_to survey_path(survey),:class => "button" do %> <span>add questions to <%= survey.name %></span> <% end %>
这不会显示:class.
需要纠正的是什么?
解决方法
尝试添加=使其成为<%=%>
<%= link_to survey_path(survey),:class => "button" do %> <span>add questions to <%= survey.name %></span> <% end %>
In the view code in Rails 3 applications it’s sometimes necessary to
use <%= instead of <% at the beginning of blocks that output content,
such as form_for.
因为它只是一个跨度,你为什么不这样做
<%= link_to "add questions to #{survey.name}",survey_path(survey),:class => "button" %>