diff --git a/app/models/question.rb b/app/models/question.rb index 5f8289e4..a7d553dd 100644 --- a/app/models/question.rb +++ b/app/models/question.rb @@ -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