an error is now raised if the user does not want to receive anonymous questions
This commit is contained in:
parent
bc94a729a6
commit
175e113af1
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue