class Vote
Protected Instance Methods
should_be_unique()
click to toggle source
# File lib/mongo_mapper/plugins/voteable/vote.rb, line 18 def should_be_unique vote = Vote.first({ :voteable_type => self.voteable_type, :voteable_id => self.voteable_id, :voter_id => self.voter_id }) valid = vote.nil? return true if valid self.errors.add(:voter, "You already voted on this #{self.voteable_type}.") return false end
should_not_be_owner()
click to toggle source
# File lib/mongo_mapper/plugins/voteable/vote.rb, line 32 def should_not_be_owner return true unless self.voteable.user_id == self.voter_id self.errors.add(:vote, "You cant vote on this #{self.voteable_type}.") return false end