Created
December 6, 2010 12:34
-
-
Save Orion98MC/730226 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) } | |
scope :deletable, old.sent | |
def self.per_page; 10;end | |
end | |
controller action: | |
def notifications | |
@notifications = Notification.not_sent.paginate(:page => params[:page]) | |
render | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment