I have a product display page which is displaying all products on website. Here I want to filter products as per their Owner. As a start, i am displaying owner names on page using each loop:
<% @products.each do |p| %>
<%= link_to p.user.profile.first_name, store_index_path %>
<% end %>
But as owner has multiple products, his name gets displayed multiple times. How to show the name only once?
In simple way you can do like this: