Skip to content

Instantly share code, notes, and snippets.

@kastner
Created November 10, 2008 19:06
Show Gist options
  • Select an option

  • Save kastner/23586 to your computer and use it in GitHub Desktop.

Select an option

Save kastner/23586 to your computer and use it in GitHub Desktop.
named_scope :newest_first, :order => "start_at desc"
named_scope :ending_first, :order => "end_at"
named_scope :past_day, :conditions => ["start_at >= ? AND start_at <= ?", Time.now - 1.day, Time.now]
named_scope :does_expire, :conditions => { :does_not_expire => false}
named_scope :never_expire, :conditions => { :does_not_expire => true}
named_scope :active1, :conditions => { :status => true }
named_scope :started, :conditions => ["start_at <= ? OR start_at IS NULL", Time.now]
named_scope :not_ended, :conditions => ["end_at >= ? OR end_at IS NULL", Time.now]
named_scope :ending, :conditions => ["end_at >= ? AND end_at <= ?", Time.now, Time.now + 7.days]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment