Sha256: b06093855b9df300b5a98eb20e53f2d7caf0da9bacde76168d27b0289ef0e662
Contents?: true
Size: 647 Bytes
Versions: 10
Compression:
Stored size: 647 Bytes
Contents
module Neutral class Vote < ActiveRecord::Base before_update :avoid_duplication validates_inclusion_of :value, in: [0,1] validates_presence_of :voteable_type, :voteable_id, :value belongs_to :voteable, polymorphic: true belongs_to :voter, class_name: Neutral.config.vote_owner_class.classify include Neutral::Model::VoteCached def nature value == 1 ? :positive : :negative end def main_attributes attributes.symbolize_keys.except(:id, :voter_id, :created_at, :updated_at) end private def avoid_duplication raise Errors::DuplicateVote unless self.changed? end end end
Version data entries
10 entries across 10 versions & 1 rubygems