Retrospring/app/models/inbox.rb

20 lines
476 B
Ruby
Raw Normal View History

2014-11-10 14:45:36 -08:00
class Inbox < ActiveRecord::Base
belongs_to :user
2014-11-10 22:10:02 -08:00
belongs_to :question
2015-01-03 13:27:14 -08:00
before_create do
raise "User does not want to receive anonymous questions" if self.question.author_is_anonymous and !self.user.privacy_allow_anonymous_questions?
end
def answer(answer_content, user)
answer = user.answer(self.question, answer_content)
self.destroy
2014-12-12 14:14:32 -08:00
answer
end
def remove
2014-12-14 03:19:52 -08:00
self.question.destroy if self.question.can_be_removed?
self.destroy
end
2014-11-10 14:45:36 -08:00
end