Retrospring/app/models/question.rb

16 lines
337 B
Ruby

class Question < ActiveRecord::Base
belongs_to :user
has_many :answers
validates :content, length: { maximum: 255 }
class << self
def can_be_removed
return false if self.answers.count > 0
return false if Inbox.where(question: self).count > 0
self.user.decrement! :asked_count
true
end
end
end