diaspora/app/models/block.rb
James Fleming 66a07bd938 Remove attributes protection.
Use a blacklist approach instead of a blacklist approach in Profile#receive.

Remove attr_accessible from models and make specs pass.
2013-08-02 11:39:06 +02:00

18 lines
424 B
Ruby

class Block < ActiveRecord::Base
belongs_to :person
belongs_to :user
delegate :name, to: :person, prefix: true
validates :user_id, :presence => true
validates :person_id, :presence => true, :uniqueness => { :scope => :user_id }
validate :not_blocking_yourself
def not_blocking_yourself
if self.user.person.id == self.person_id
errors[:person_id] << "stop blocking yourself!"
end
end
end