Ruby on rails 在Rails中将link_与post.title一起使用?
我有以下代码:Ruby on rails 在Rails中将link_与post.title一起使用?,ruby-on-rails,Ruby On Rails,我有以下代码: <% @posts.each do |post| %> <h2>Title: <%= post.title %></h2> <p>Author: <%= post.user.username %></p> <p>Created At: <%= post.created_at %></p> <p>Content: &
<% @posts.each do |post| %>
<h2>Title: <%= post.title %></h2>
<p>Author: <%= post.user.username %></p>
<p>Created At: <%= post.created_at %></p>
<p>Content: <%= post.content %></p>
<p>Votes: <%= post.total_votes %></p>
<p>Comments: <%= post.comments_count %></p>
<ul>
<li><%= link_to 'Show', post %></li>
<li><%= link_to 'Edit', edit_post_path(post) %></li>
<li><%= link_to 'Destroy', post, confirm: 'Are you sure?', method: :delete %></li>
</ul>
标题:
作者:
创建于:
内容:
投票:
评论:
我想要这样的东西:
<h2><%= link_to "post.title" %></h2>
正确的方法是什么?
如果您想用var添加文本,您也可以这样做