ruby on rails - Show an object's rating with letsrate -
i'm creating music album review site, user posts album reviews (pins), , select 1-5 stars display on show page. i'm using letsrate gem , works fine input stars on form when submitting new pin , editing. need display input on show page.
when have <%= @pin.rates %>
on show page, 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 stars: 4.0 display 4 stars. (and not allow them edited in show view)
this 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 question posted, doesn't explain how use helper: displaying individual user ratings (letsrate gem)
if use <%= rating_for @pin =>
, stars show up, can rerate them, not good. need disable them.
any suggestions appreciated.
you can try:
<%= @pin.rates[:stars].to_i %>
Comments
Post a Comment