0

假设我有这个:

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>
4

1 回答 1

0

这是解决方案:

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

希望它可以帮助某人。

于 2012-01-28T17:35:16.740 回答