Sha256: 72d2ed4ac19f626bcab4aabebb973e0bfeb8b15cfaa3f9833d59c11b59b046e6

Contents?: true

Size: 608 Bytes

Versions: 6

Compression:

Stored size: 608 Bytes

Contents

module Recommendable
  class Dislike < ActiveRecord::Base
    self.table_name = 'recommendable_dislikes'
    attr_accessible :user_id, :dislikeable_id, :dislikeable_type

    belongs_to :user, :class_name => Recommendable.user_class.to_s, :foreign_key => :user_id
    belongs_to :dislikeable, :polymorphic => true
    
    validates :user_id, :uniqueness => { :scope => [:dislikeable_id, :dislikeable_type],
                                         :message => "has already disliked this item" }

    def dislikeable_type=(sType)
      super sType.to_s.classify.constantize.base_class.to_s
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
recommendable-1.1.4 app/models/recommendable/dislike.rb
recommendable-1.1.3 app/models/recommendable/dislike.rb
recommendable-1.1.2 app/models/recommendable/dislike.rb
recommendable-1.1.1 app/models/recommendable/dislike.rb
recommendable-1.0.0 app/models/recommendable/dislike.rb
recommendable-0.2.1.1 app/models/recommendable/dislike.rb