Module: ActsAsRateable::Rateable::Core::ClassMethods
- Defined in:
- lib/acts_as_rateable/acts_as_rateable/core.rb
Instance Method Summary collapse
-
#ratings_by_user(user) ⇒ Object
Helper class method to lookup ratings for the mixin rateable type written by a given user.
-
#ratings_for(obj) ⇒ Object
Helper method to lookup for ratings for a given object.
Instance Method Details
#ratings_by_user(user) ⇒ Object
Helper class method to lookup ratings for the mixin rateable type written by a given user.
This method is NOT equivalent to Rating.find_ratings_for_user
22 23 24 25 26 27 28 |
# File 'lib/acts_as_rateable/acts_as_rateable/core.rb', line 22 def (user) rateable = ActiveRecord::Base.send(:class_name_of_active_record_descendant, self).to_s scoped( :conditions => { :user_id => user.id, :rateable_type => rateable }, :order => 'created_at DESC' ) end |
#ratings_for(obj) ⇒ Object
Helper method to lookup for ratings for a given object. This method is equivalent to obj.ratings
11 12 13 14 15 16 17 |
# File 'lib/acts_as_rateable/acts_as_rateable/core.rb', line 11 def (obj) rateable = ActiveRecord::Base.send(:class_name_of_active_record_descendant, self).to_s scoped( :conditions => { :rateable_id => obj.id, :rateable_type => rateable }, :order => 'created_at DESC' ) end |