I'm using the jquery raty gem and I want to add the rating for each user below their username. This is what I have in the products.show html.erb:
<div class="row">
<div class="col-md-12">
<div class="ratings">
<h1> Ratings </h1>
<% @product.ratings.each do |rating| %>
<em> User: </em><%= User.find(rating.user_id.to_i).username.capitalize %>
<% end %>
<%= render @product.ratings %>
<div>
<!-- What I see is the following: -->
Username1: Username2:
(stars rating1)
(stars rating2)
<!-- And I want this: -->
Username1:
(stars rating1)
Username2:
(stars rating2)
I've tried to close the loop by placing the end below the render @product.ratings but by doing so I get all the ratings shown twice.
I did it, using the each with index. So the code is: