class Rating

Public Class Methods

find_similar(rating) click to toggle source
# File lib/generators/rateme/templates/model.rb, line 10
def self.find_similar(rating)
  Rating.find(
    :first, 
    :conditions => {
      :ip_address => rating.ip_address,
      :rateable_id => rating.rateable_id,
      :rateable_type => rating.rateable_type 
    }
  )
end

Protected Instance Methods

delete_last_rating() click to toggle source
# File lib/generators/rateme/templates/model.rb, line 26
def delete_last_rating
  if (rating = Rating.find_similar(self))
    rating.destroy
  end
end
maximum_value_is_not_breached() click to toggle source
# File lib/generators/rateme/templates/model.rb, line 22
def maximum_value_is_not_breached
  errors.add('value', 'is not in the range') unless rateable.rating_range.include?(value)
end