add questions to-6ren">
gpt4 book ai didi

ruby-on-rails - 如何为 link_to block 传递 html?

转载 作者:行者123 更新时间:2023-12-03 00:49:52 24 4
gpt4 key购买 nike

我试图用 html 传递 link_to block ,但无法获取它。我尝试了其他一些方法但没有成功,所以我将使用我的原始代码:

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

关于ruby-on-rails - 如何为 link_to block 传递 html?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11263968/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com