Module: ActsAsRateable::Rateable::Core::InstanceMethods
- Defined in:
- lib/acts_as_rateable/acts_as_rateable/core.rb
Instance Method Summary collapse
-
#rate_it(rating, user) ⇒ Object
Helper method that defaults the current time to the submitted field.
-
#rated_by_user?(user) ⇒ Boolean
Check to see if a user already rated this rateable.
-
#rating ⇒ Object
Helper method that returns the average rating.
Instance Method Details
#rate_it(rating, user) ⇒ Object
Helper method that defaults the current time to the submitted field.
33 34 35 36 |
# File 'lib/acts_as_rateable/acts_as_rateable/core.rb', line 33 def rate_it(, user) .where(:user_id => user.id).delete_all if user.present? << ActsAsRateable::Rating.new(:rating => .to_i, :user_id => user.try(:id)) end |
#rated_by_user?(user) ⇒ Boolean
Check to see if a user already rated this rateable
44 45 46 |
# File 'lib/acts_as_rateable/acts_as_rateable/core.rb', line 44 def rated_by_user?(user) .where(:user_id => user.id).count > 0 end |
#rating ⇒ Object
Helper method that returns the average rating
39 40 41 |
# File 'lib/acts_as_rateable/acts_as_rateable/core.rb', line 39 def .average(:rating).to_f end |