an error is now raised if the user does not want to receive anonymous questions

This commit is contained in:
nilsding 2015-01-03 22:06:23 +01:00
parent bc94a729a6
commit 175e113af1
1 changed files with 4 additions and 0 deletions

View File

@ -5,6 +5,10 @@ class Question < ActiveRecord::Base
validates :content, length: { maximum: 255 }
before_create do
raise "User does not want to receive anonymous questions" if self.author_is_anonymous and !self.user.privacy_allow_anonymous_questions?
end
before_destroy do
user.decrement! :asked_count unless self.author_is_anonymous
end