2020-04-18 15:59:18 -07:00
class Inbox < ApplicationRecord
2014-11-10 14:45:36 -08:00
belongs_to :user
2014-11-10 22:10:02 -08:00
belongs_to :question
2014-11-30 09:05:51 -08:00
2015-01-03 13:27:14 -08:00
before_create do
2015-01-27 08:51:39 -08:00
raise " User does not want to receive anonymous questions " if self . question . author_is_anonymous and self . question . author_name != 'justask' and ! self . user . privacy_allow_anonymous_questions?
2015-01-03 13:27:14 -08:00
end
2015-01-03 09:09:56 -08:00
def answer ( answer_content , user )
answer = user . answer ( self . question , answer_content )
2014-11-30 09:05:51 -08:00
self . destroy
2014-12-12 14:14:32 -08:00
answer
2014-11-30 09:05:51 -08:00
end
def remove
2014-12-14 03:19:52 -08:00
self . question . destroy if self . question . can_be_removed?
2014-11-30 09:05:51 -08:00
self . destroy
end
2014-11-10 14:45:36 -08:00
end