- def unread_reports
- resolved_at.present? ? reports.where("updated_at >= ?", resolved_at) : reports
- end
-
- include AASM
- aasm :column => :status, :no_direct_assignment => true do
- state :open, :initial => true
- state :ignored
- state :resolved
-
- event :ignore do
- transitions :from => :open, :to => :ignored
- end
-
- event :resolve do
- transitions :from => :open, :to => :resolved
- after do
- self.resolved_at = Time.now.getutc
- end
- end
-
- event :reopen do
- transitions :from => :resolved, :to => :open
- transitions :from => :ignored, :to => :open
- end
-
- end