Show an object's rating with letsrate
I'm creating a music album review site, where the user posts album reviews
(pins), and will select 1-5 stars to display on the show page. I'm using
the letsrate gem and it works fine to input the stars on the form when
submitting the new pin and editing. Now I need to display that input on
the show page.
When I have <%= @pin.rates %> on the show page, it displays this: [#<Rate
id: 8, rater_id: 1, rateable_id: 36, rateable_type: "Pin", stars: 4.0,
dimension: nil, created_at: "2013-08-19 22:28:36", updated_at: "2013-08-19
22:28:36">]
I need to get that stars: 4.0 to display the four stars. (and not allow
them to be edited in the show view)
This is my rate model:
class Rate < ActiveRecord::Base
belongs_to :rater, :class_name => "User"
belongs_to :rateable, :polymorphic => true
belongs_to :pin
attr_accessible :rate, :dimension
end
I saw this question posted, but it doesn't explain much about how to use
the helper: Displaying Individual User Ratings (letsrate gem)
Any suggestions would be greatly appreciated.
No comments:
Post a Comment