Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 18f939d710
Fetching contributors…

Cannot retrieve contributors at this time

20 lines (16 sloc) 0.803 kb
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, :counter_cache => :dislikes_count
belongs_to :dislikeable, :polymorphic => true, :counter_cache => :dislikes_count
validates :user_id, :uniqueness => { :scope => [:dislikeable_id, :dislikeable_type],
:message => "has already disliked this item" },
:presence => true
validates_presence_of :dislikeable_id
validates_presence_of :dislikeable_type
def dislikeable_type=(sType)
super sType.to_s.classify.constantize.base_class.to_s
end
end
end
Jump to Line
Something went wrong with that request. Please try again.