~acesuares/qspell/trunk

« back to all changes in this revision

Viewing changes to vendor/plugins/vote_fu/lib/models/vote.rb

  • Committer: Ace Suares
  • Date: 2009-10-07 06:16:20 UTC
  • Revision ID: ace@suares.an-20091007061620-j39st30s42edy61t
 * voting with vote_fu

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
class Vote < ActiveRecord::Base
 
2
 
 
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"
 
7
 
 
8
  # NOTE: Votes belong to the "voteable" interface, and also to voters
 
9
  belongs_to :voteable, :polymorphic => true
 
10
  belongs_to :voter,    :polymorphic => true
 
11
  
 
12
  attr_accessible :vote, :voter, :voteable
 
13
 
 
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]
 
16
 
 
17
end
 
 
b'\\ No newline at end of file'