Sha256: b69ee3b8c0377bee09bf0fd92baa5f10446c893d3ae0cf7864fb3c84f539b2f3

Contents?: true

Size: 762 Bytes

Versions: 9

Compression:

Stored size: 762 Bytes

Contents

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

<% if options[:unique_voting] == true %>
  # 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

9 entries across 9 versions & 1 rubygems

Version Path
thumbs_up-0.5.2 lib/generators/thumbs_up/templates/vote.rb
thumbs_up-0.5.1 lib/generators/thumbs_up/templates/vote.rb
thumbs_up-0.5.0 lib/generators/thumbs_up/templates/vote.rb
thumbs_up-0.4.6 lib/generators/thumbs_up/templates/vote.rb
thumbs_up-0.4.5 lib/generators/thumbs_up/templates/vote.rb
thumbs_up-0.4.4 lib/generators/thumbs_up/templates/vote.rb
thumbs_up-0.4.3 lib/generators/thumbs_up/templates/vote.rb
thumbs_up-0.4.1 lib/generators/thumbs_up/templates/vote.rb
thumbs_up-0.4 lib/generators/thumbs_up/templates/vote.rb