module ThumbsUp::ActsAsVoter::ClassMethods

Public Instance Methods

acts_as_voter() click to toggle source
# File lib/acts_as_voter.rb, line 9
def acts_as_voter

  # If a voting entity is deleted, keep the votes.
  # If you want to nullify (and keep the votes), you'll need to remove
  # the unique constraint on the [ voter, voteable ] index in the database.
  # has_many :votes, :as => :voter, :dependent => :nullify
  # Destroy voter's votes when the voter is deleted.
  has_many ThumbsUp.configuration[:voter_relationship_name],
           :as => :voter,
           :dependent => :destroy,
           :class_name => 'Vote'

  include ThumbsUp::ActsAsVoter::InstanceMethods
  extend  ThumbsUp::ActsAsVoter::SingletonMethods
end