Sha256: 7da95445639e26f3e4b92b0fd860649b04c8661bf790ed3ebf8d247e7e847f3c

Contents?: true

Size: 592 Bytes

Versions: 1

Compression:

Stored size: 592 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" }
    def ignorable_type=(sType)
      super sType.to_s.classify.constantize.base_class.to_s
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
recommendable-0.2.1.1 app/models/recommendable/ignore.rb