mirror of
https://github.com/Retrospring/retrospring.git
synced 2025-01-19 13:26:04 +01:00
19 lines
454 B
Ruby
19 lines
454 B
Ruby
class Inbox < ActiveRecord::Base
|
|
belongs_to :user
|
|
belongs_to :question
|
|
|
|
def answer(answer, user)
|
|
answer = Answer.create!(content: answer,
|
|
user: user,
|
|
question: self.question)
|
|
user.increment! :answered_count
|
|
self.question.increment! :answer_count
|
|
self.destroy
|
|
answer
|
|
end
|
|
|
|
def remove
|
|
self.question.destroy if self.question.can_be_removed?
|
|
self.destroy
|
|
end
|
|
end
|