【发布时间】:2012-01-22 12:21:09
【问题描述】:
假设我有这个:
link_to "Profile", profile_path(@profile)
# => <a href="/profiles/1">Profile</a>
但如果我只需要像 <a href="/profiles/1"><h1>Title</h1><p>some text</p></a> 这样的 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_path(@profile) 也许?
-
抱歉,我必须编辑才能准确询问我要查找的内容..
-
刚刚在有关使用块的文档中找到。谢谢!
标签: ruby-on-rails-3 view-helpers