mirror of
https://github.com/Retrospring/retrospring.git
synced 2024-11-20 16:19:52 +01:00
fixed this thing.
This commit is contained in:
parent
72f0f577a1
commit
0ebf918d83
2 changed files with 6 additions and 8 deletions
|
@ -13,7 +13,7 @@ class Inbox < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def remove
|
def remove
|
||||||
self.question.destroy if self.question.can_be_removed
|
self.question.destroy if self.question.can_be_removed?
|
||||||
self.destroy
|
self.destroy
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,12 +4,10 @@ class Question < ActiveRecord::Base
|
||||||
|
|
||||||
validates :content, length: { maximum: 255 }
|
validates :content, length: { maximum: 255 }
|
||||||
|
|
||||||
class << self
|
def can_be_removed?
|
||||||
def can_be_removed
|
return false if self.answers.count > 0
|
||||||
return false if self.answers.count > 0
|
return false if Inbox.where(question: self).count > 1
|
||||||
return false if Inbox.where(question: self).count > 0
|
self.user.decrement! :asked_count
|
||||||
self.user.decrement! :asked_count
|
true
|
||||||
true
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue