yozzz
yozzz

Reputation: 1277

Letsrate gem - doesn't show stars

I'm trying to use letsrate gem and follow the instructions on github. I already have models user.rb and hotel.rb. Also I use command rails g letsrate user and add functions letsrate_rater, letsrate_rateable to models.

Model user.rb :

class User < ActiveRecord::Base
  letsrate_rater
end

Model hotel.rb :

class Hotel < ActiveRecord::Base
  letsrate_rateable "rating"
end

The problem is, when i try to output current variable with rating it doesn't show any stars.

View show.html.erb :

...
<div>Rating: <%= rating_for @hotel, "rating" %></div>

@hotel variable isn't empty, i'm getting above @hotel.title and it's working. When I'm doing "expect element" it shows me:

'Rating: ' 
<div class="star" data-classname="Hotel" data-dimension="rating"
     data-id="4" data-rating="0" data-star-count="5"></div>

So helper is working, but there are now stars. Maybe something with pipeline? Any idea?

Upvotes: 0

Views: 763

Answers (1)

yozzz
yozzz

Reputation: 1277

We should include javascript files. Add in view (in my case show.html.erb):

<% content_for :javascript_includes do %>
  <%= javascript_include_tag 'jquery.raty.js','letsrate.js'%>
<% end %> 

And after add in application.html.erb:

<%= yield :javascript_includes %> 

Upvotes: 3

Related Questions