Created
April 20, 2009 22:17
-
-
Save anotherjesse/98798 to your computer and use it in GitHub Desktop.
an attempt to make a ranged named_proxy
This file contains hidden or 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 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