mirror of
https://github.com/Retrospring/retrospring.git
synced 2025-01-31 17:09:07 +01:00
21 lines
430 B
Ruby
21 lines
430 B
Ruby
class Inbox < ActiveRecord::Base
|
|
belongs_to :user
|
|
belongs_to :question
|
|
|
|
def answer(answer, user)
|
|
Answer.create(content: answer,
|
|
user: user,
|
|
question: self.question)
|
|
user.increment! :answered_count
|
|
self.destroy
|
|
end
|
|
|
|
def remove
|
|
unless self.question.user.nil?
|
|
self.question.user.decrement! :asked_count
|
|
end
|
|
|
|
self.question.destroy
|
|
self.destroy
|
|
end
|
|
end
|