Ruby on rails 在rails链接中放置HTML
我正在使用Twitter引导,我想将下面的列表组项转换为link_to,即link_to(post.title,post_path),但下面的链接包含一个h4和p元素。我将如何将其合并?我想把它全部转换成一个字符串,但那样的话,转义html就不会有问题了吗Ruby on rails 在rails链接中放置HTML,ruby-on-rails,Ruby On Rails,我正在使用Twitter引导,我想将下面的列表组项转换为link_to,即link_to(post.title,post_path),但下面的链接包含一个h4和p元素。我将如何将其合并?我想把它全部转换成一个字符串,但那样的话,转义html就不会有问题了吗 <% @posts.each do |post| %> <a href="#" class="list-group-item"> <h4 class="list-group-item-heading"
<% @posts.each do |post| %>
<a href="#" class="list-group-item">
<h4 class="list-group-item-heading"><%= post.title %></h4>
<p class="list-group-item-text"><%= post.content %></p>
</a>
<% end %>
链接到
接受块
<%= link_to post_path(post) do %>
<h4 class="list-group-item-heading"><%= post.title %></h4>
<p class="list-group-item-text"><%= post.content %></p>
<% end %>
如果你想要任何其他的选择,你会把它们放在最后,但在区块之前
<%= link_to post_path(post), remote: true do %>
给您:
<% @posts.each do |post| %>
<%= link_to post_path(post) do %>
<h4 class="list-group-item-heading"><%= post.title %></h4>
<p class="list-group-item-text"><%= post.content %></p>
<% end %>
<% end %>
要了解有关链接到的更多信息,请执行以下操作:谢谢,我刚刚在链接到中添加了:class=>“列表组项目”。我到处都能看到你:)