假设我有这个:
link_to "Profile", profile_path(@profile)
# => <a href="/profiles/1">Profile</a>
但是,如果我只需要像这样的 href 链接<a href="/profiles/1"><h1>Title</h1><p>some text</p></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>