我是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>
并且希望CCD_ 2类充当CCD_ 3
您可以将块传递给link_to
方法。
<%= link_to post do %>
<div class="card-body">
<h4><%= post.title %></h4>
...
</div>
<% end %>