Sha256: bc28df434b1d0b73d40bcf790dfaac8173f8d7bac377cca7f418e850e24a2b50

Contents?: true

Size: 738 Bytes

Versions: 6

Compression:

Stored size: 738 Bytes

Contents

require 'acts_as_votable/helpers/words'

module ActsAsVotable
  class Vote < ::ActiveRecord::Base

    include Helpers::Words

    if ::ActiveRecord::VERSION::MAJOR < 4
      attr_accessible :votable_id, :votable_type,
        :voter_id, :voter_type,
        :votable, :voter,
        :vote_flag, :vote_scope
    end

    belongs_to :votable, :polymorphic => true
    belongs_to :voter, :polymorphic => true

    scope :up, lambda{ where(:vote_flag => true) }
    scope :down, lambda{ where(:vote_flag => false) }
    scope :for_type, lambda{ |klass| where(:votable_type => klass) }
    scope :by_type,  lambda{ |klass| where(:voter_type => klass) }

    validates_presence_of :votable_id
    validates_presence_of :voter_id

  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
acts_as_votable-0.10.0 lib/acts_as_votable/vote.rb
acts_as_votable-0.9.0 lib/acts_as_votable/vote.rb
acts_as_votable-0.8.0 lib/acts_as_votable/vote.rb
acts_as_votable-0.7.1 lib/acts_as_votable/vote.rb
acts_as_votable-0.7.0 lib/acts_as_votable/vote.rb
acts_as_votable-0.6.0 lib/acts_as_votable/vote.rb