Sha256: e746adf336785556a6badd41ec0180600591098bfb3db61ea6d861bde14b259d
Contents?: true
Size: 737 Bytes
Versions: 8
Compression:
Stored size: 737 Bytes
Contents
# frozen_string_literal: true require "acts_as_votable/helpers/words" module ActsAsVotable class Vote < ::ActiveRecord::Base include Helpers::Words if defined?(ProtectedAttributes) attr_accessible :votable_id, :votable_type, :voter_id, :voter_type, :votable, :voter, :vote_flag, :vote_scope end belongs_to :votable, polymorphic: true belongs_to :voter, polymorphic: true scope :up, -> { where(vote_flag: true) } scope :down, -> { where(vote_flag: false) } scope :for_type, ->(klass) { where(votable_type: klass.to_s) } scope :by_type, ->(klass) { where(voter_type: klass.to_s) } validates_presence_of :votable_id validates_presence_of :voter_id end end
Version data entries
8 entries across 8 versions & 1 rubygems