Retrospring/app/models/question.rb

16 lines
337 B
Ruby
Raw Normal View History

2014-10-27 22:36:38 -07:00
class Question < ActiveRecord::Base
belongs_to :user
2014-12-07 11:13:45 -08:00
has_many :answers
2014-12-08 06:34:37 -08:00
2014-12-08 14:02:31 -08:00
validates :content, length: { maximum: 255 }
2014-12-14 03:03:57 -08:00
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
2014-10-27 22:36:38 -07:00
end