Ruby on rails 3 如何显示包含html标记的链接html代码?
假设我有这个:Ruby on rails 3 如何显示包含html标记的链接html代码?,ruby-on-rails-3,view-helpers,Ruby On Rails 3,View Helpers,假设我有这个: link_to "Profile", profile_path(@profile) # => <a href="/profiles/1">Profile</a> 链接到“Profile”,Profile路径(@Profile) # => 但是如果我只需要href链接,比如 有什么rails方法可以做到这一点吗 编辑:这是块用法的解决方案,如下所示: <%= link_to(@profile) do %> <strong>
link_to "Profile", profile_path(@profile)
# => <a href="/profiles/1">Profile</a>
链接到“Profile”,Profile路径(@Profile)
# =>
但是如果我只需要href链接,比如
有什么rails方法可以做到这一点吗
编辑:这是块用法的解决方案,如下所示:
<%= link_to(@profile) do %>
<strong><%= @profile.name %></strong> -- <span>Check it out!</span>
<% end %>
# => <a href="/profiles/1">
<strong>David</strong> -- <span>Check it out!</span>
</a>
——看看吧!
# =>
这就是解决方案:
<%= link_to(@profile) do %>
<strong><%= @profile.name %></strong> -- <span>Check it out!</span>
<% end %>
# => <a href="/profiles/1">
<strong>David</strong> -- <span>Check it out!</span>
</a>
——看看吧!
# =>
希望它能帮助别人。链接到“”,配置文件路径(@profile)也许?对不起,我必须编辑以询问我到底在寻找什么。刚刚在文档中找到关于使用块的内容。谢谢