Sha256: 8f562a6fccd81317e5b7dd5c2000d0d11cd9265d4964e5a486a8a8b57c9ab45c

Contents?: true

Size: 647 Bytes

Versions: 5

Compression:

Stored size: 647 Bytes

Contents

require 'acts_as_votable/helpers/words'

module ActsAsVotable
  class Vote < ::ActiveRecord::Base

    include Helpers::Words

    attr_accessible :votable_id, :votable_type,
      :voter_id, :voter_type,
      :votable, :voter,
      :vote_flag

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

    scope :up, where(:vote_flag => true)
    scope :down, 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

5 entries across 5 versions & 2 rubygems

Version Path
acts_as_votable-0.4.0 lib/acts_as_votable/vote.rb
jy-acts_as_votable-0.3.1 lib/acts_as_votable/vote.rb
acts_as_votable-0.3.1 lib/acts_as_votable/vote.rb
acts_as_votable-0.3.0 lib/acts_as_votable/vote.rb
acts_as_votable-0.2.0 lib/acts_as_votable/vote.rb