Sha256: f788475c7c45639eefbc536538a46a5e34ec7fb04ef2be8aefd2ef9b61587162

Contents?: true

Size: 753 Bytes

Versions: 10

Compression:

Stored size: 753 Bytes

Contents

module Rostra
  class Vote < ActiveRecord::Base

    scope :for_voter, lambda { |*args| where(["voter_id = ? AND voter_type = ?", args.first.id, args.first.class.name]) }
    scope :for_voteable, lambda { |*args| where(["voteable_id = ? AND voteable_type = ?", args.first.id, args.first.class.name]) }
    scope :recent, lambda { |*args| where(["created_at > ?", (args.first || 2.weeks.ago)]) }
    scope :descending, order("created_at DESC")

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

    attr_accessible :vote, :voter, :voteable


    # Comment out the line below to allow multiple votes per user.
    validates_uniqueness_of :voteable_id, :scope => [:voteable_type, :voter_type, :voter_id]

  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
rostra-0.0.10 app/models/rostra/vote.rb
rostra-0.0.9 app/models/rostra/vote.rb
rostra-0.0.8 app/models/rostra/vote.rb
rostra-0.0.7 app/models/rostra/vote.rb
rostra-0.0.6 app/models/rostra/vote.rb
rostra-0.0.5 app/models/rostra/vote.rb
rostra-0.0.4 app/models/rostra/vote.rb
rostra-0.0.3 app/models/rostra/vote.rb
rostra-0.0.2 app/models/rostra/vote.rb
rostra-0.0.1 app/models/rostra/vote.rb