module LoveMonster class Love < ActiveRecord::Base default_scope { order('created_at DESC') } belongs_to :person_to, :class_name => Person, :foreign_key => "to_user_id" belongs_to :person_from, :class_name => Person, :foreign_key => "from_user_id" has_many :likes validates :from_user_id, :to_user_id, :reason, :presence => true validate :ensure_to_and_from_are_distinct def ensure_to_and_from_are_distinct errors.add(:to_user_id, "You love yourself enough already. Go love someone else!") if from_user_id == to_user_id end end end