lib/mongoid_rating/model.rb in mongoid_rating-0.0.2 vs lib/mongoid_rating/model.rb in mongoid_rating-0.1.0

- old
+ new

@@ -45,9 +45,13 @@ where("#{field}_data.rater_id" => rater.id, "#{field}_data.rater_type" => rater.class.to_s) } scope :#{field}_in, ->(range) { where(#{savg}.gte => range.begin, #{savg}.lte => range.end) } + + scope :by_#{field}, -> { + order_by([#{savg}, :desc]) + } scope :highest_#{field}, -> { where(#{savg}.ne => nil).order_by([#{savg}, :desc]) } def #{field}!(value, rater)