Sha256: 7aefc31ec41a5d256fe5cd6a80f751ec61abc9de9e416cb352b485f0b447d8c7
Contents?: true
Size: 940 Bytes
Versions: 1
Compression:
Stored size: 940 Bytes
Contents
module ActsAsVotable class Vote < ::ActiveRecord::Base attr_accessible :votable_id, :votable_type, :voter_id, :voter_type, :votable, :voter, :vote_flag belongs_to :votable, :polymorphic => true belongs_to :voter, :polymorphic => true validates_presence_of :votable_id validates_presence_of :voter_id def self.true_votes ['up', 'upvote', 'like', 'liked', 'positive', 'yes', 'good', 'true', 1, true] end def self.false_votes ['down', 'downvote', 'dislike', 'disliked', 'negative', 'no', 'bad', 'false', 0, false] end ## # check is word is a true or bad vote # if the word is unknown, then it counts it as a true/good # vote. this exists to allow all voting to be good by default def self.word_is_a_vote_for word !false_votes.include? word end def self.default_voting_args { :vote => true, } end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
acts_as_votable-0.1.0 | lib/acts_as_votable/vote.rb |