Right now I have a loop that contains code I do not wish to repeat for each instance variable. I wish to put this in a partial and reuse it by changing the @new_posts instance variable, so I can use the same template for @featured_posts and @recommended_posts that I have defined.
I'm thinking of something like this:
<%= render "posts", posts: @featured_posts %>
An example of a loop that I wish to store in a partial
<% @new_posts.each do |post| %>
<div class="col-sm-4">
<div class="thumbnail">
<img src="#">
<div class="caption">
<h4><%= link_to post.title, post %></h4>
<%= post.text.truncate_words(60, omission: '...') %>
<a href="#" class="btn btn-default btn-xs" role="button">Button</a>
</div>
</div>
</div>
<% end %>
How should I approach this? Thanks for your help!