I’m using Twitter Bootstrap and I want to turn the following list-group-item into a link_to, i.e. link_to (post.title, post_path) but the following link contains a h4 and p element. How would I incorporate this? I though of just turning it all into a string, but then would you not have a problem with escaping html?
<% @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 %>
2
Answers
link_to
accepts a blockIf you want any other options you’d put them on the end but before the block
Here you are:
To learn more about
link_to
: http://apidock.com/rails/ActionView/Helpers/UrlHelper/link_to