Skip to content

Instantly share code, notes, and snippets.

@anotherjesse
Created April 20, 2009 22:17
Show Gist options
  • Select an option

  • Save anotherjesse/98798 to your computer and use it in GitHub Desktop.

Select an option

Save anotherjesse/98798 to your computer and use it in GitHub Desktop.
an attempt to make a ranged named_proxy
class ActiveRecord::Base
named_scope :created, lambda { |date_range|
case date_range
when Range
{:conditions => ["date(created_at) in (?)", date_range]}
when Date
{:conditions => ["date(created_at) = ?", date_range]}
else
{:conditions => '1=1'}
end
}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment