Sha256: 16b6275ccb0b849bdd61d51c8e07e4e43497cbc51339db032a3f1f2c3e79b12e

Contents?: true

Size: 722 Bytes

Versions: 3

Compression:

Stored size: 722 Bytes

Contents

module Recommendable
  class Ignore < ActiveRecord::Base
    self.table_name = 'recommendable_ignores'
    attr_accessible :user_id, :ignorable_id, :ignorable_type

    belongs_to :user, :class_name => Recommendable.user_class.to_s, :foreign_key => :user_id
    belongs_to :ignorable, :polymorphic => true
    
    validates :user_id, :uniqueness => { :scope => [:ignorable_id, :ignorable_type],
                                         :message => "has already ignored this item" },
                        :presence => true
    validates_presence_of :ignorable_id
    validates_presence_of :ignorable_type
    
    def ignorable_type=(sType)
      super sType.to_s.classify.constantize.base_class.to_s
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
recommendable-1.1.7 app/models/recommendable/ignore.rb
recommendable-1.1.6 app/models/recommendable/ignore.rb
recommendable-1.1.5 app/models/recommendable/ignore.rb