如何将 "link_to" 放在整张卡片下?
how to put "link_to" under an entire card?
我是Ruby的初学者,我在这个疑问中徘徊了好几个小时。如何将 "link_to"
放在整张卡片下?我有这个代码:
<div class = "card-body">
<h4> <% = link_to post.title, post%> </h4>
<div class = "text-muted mb-2">
<em> By <% = post.author%> (<% = l (post.created_at, format:: long)%>) </em>
</div>
<p> <% = post.body.truncate (220)%> </p>
<p class = "text-muted"> <% = pluralize (post.comments.count, 'Comment')%> </p>
</div>
并希望 "card-body"
class 发挥 "link_to"
的作用
您可以将块传递给 link_to
方法。
<%= link_to post do %>
<div class="card-body">
<h4><%= post.title %></h4>
...
</div>
<% end %>
我是Ruby的初学者,我在这个疑问中徘徊了好几个小时。如何将 "link_to"
放在整张卡片下?我有这个代码:
<div class = "card-body">
<h4> <% = link_to post.title, post%> </h4>
<div class = "text-muted mb-2">
<em> By <% = post.author%> (<% = l (post.created_at, format:: long)%>) </em>
</div>
<p> <% = post.body.truncate (220)%> </p>
<p class = "text-muted"> <% = pluralize (post.comments.count, 'Comment')%> </p>
</div>
并希望 "card-body"
class 发挥 "link_to"
您可以将块传递给 link_to
方法。
<%= link_to post do %>
<div class="card-body">
<h4><%= post.title %></h4>
...
</div>
<% end %>