1
class Vote < ActiveRecord::Base
3
named_scope :for_voter, lambda { |*args| {:conditions => ["voter_id = ? AND voter_type = ?", args.first.id, args.first.type.name]} }
4
named_scope :for_voteable, lambda { |*args| {:conditions => ["voteable_id = ? AND voteable_type = ?", args.first.id, args.first.type.name]} }
5
named_scope :recent, lambda { |*args| {:conditions => ["created_at > ?", (args.first || 2.weeks.ago).to_s(:db)]} }
6
named_scope :descending, :order => "created_at DESC"
8
# NOTE: Votes belong to the "voteable" interface, and also to voters
9
belongs_to :voteable, :polymorphic => true
10
belongs_to :voter, :polymorphic => true
12
attr_accessible :vote, :voter, :voteable
14
# Uncomment this to limit users to a single vote on each item.
15
# validates_uniqueness_of :voteable_id, :scope => [:voteable_type, :voter_type, :voter_id]
b'\\ No newline at end of file'