Guest User

Untitled

a guest
Feb 20th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. class Announcement < ActiveRecord::Base
  2.  
  3. named_scope :active, lambda { { :conditions => ['starts_at <= ? AND ends_at >= ?', Time.now.utc, Time.now.utc] } }
  4. named_scope :since, lambda { |hide_time| { :conditions => (hide_time ? ['updated_at > ? OR starts_at > ?', hide_time.utc, hide_time.utc] : nil) } }
  5.  
  6. def self.current_announcements(hide_time)
  7. active.since(hide_time)
  8. end
  9.  
  10. end
Add Comment
Please, Sign In to add comment