Skip to content

Instantly share code, notes, and snippets.

View Orion98MC's full-sized avatar

Thierry Passeron Orion98MC

View GitHub Profile
class Notification < ActiveRecord::Base
serialize :device_ids # weak reference to devices
validates_presence_of :message
default_scope order("created_at DESC")
scope :ready, where("ready == ?", true)
scope :sent, where("sent_at IS NOT NULL")
scope :not_sent, where("sent_at IS NULL")
scope :sendable, not_sent.ready
scope :old, lambda{ where("updated_at < ?", 10.days.ago) }