Skip to content

Instantly share code, notes, and snippets.

@rumblex
Created July 3, 2010 23:52
Show Gist options
  • Save rumblex/462941 to your computer and use it in GitHub Desktop.
Save rumblex/462941 to your computer and use it in GitHub Desktop.
# 2.3
named_scope :last_active_since, lambda { |la| la = 10.minutes.ago if la.nil?; {:conditions => ['last_active_at >= ?', la]}}
# 3 scopes
named_scope :last_active_since, lambda { |la| la = 10.minutes.ago if la.nil?; where('last_active_at >= ?', la) }
# 3 method
def last_active_since(la = 10.minutes.ago)
where('last_active_at >= ?', la)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment