Last active
December 17, 2015 06:59
-
-
Save jcsrb/5569905 to your computer and use it in GitHub Desktop.
this screams for metaprogramming
This file contains 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
scope :created_this_hour , lambda { where("created_at BETWEEN '#{DateTime.now.beginning_of_hour}' AND '#{DateTime.now.end_of_hour}'") } | |
scope :created_this_day , lambda { where("created_at BETWEEN '#{DateTime.now.beginning_of_day}' AND '#{DateTime.now.end_of_day}'") } | |
scope :created_this_week , lambda { where("created_at BETWEEN '#{DateTime.now.beginning_of_week}' AND '#{DateTime.now.end_of_week}'") } | |
scope :created_this_month , lambda { where("created_at BETWEEN '#{DateTime.now.beginning_of_month}' AND '#{DateTime.now.end_of_month}'") } | |
scope :created_this_quarter , lambda { where("created_at BETWEEN '#{DateTime.now.beginning_of_quarter}' AND '#{DateTime.now.end_of_quarter}'") } | |
scope :created_this_year , lambda { where("created_at BETWEEN '#{DateTime.now.beginning_of_year}' AND '#{DateTime.now.end_of_year}'") } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Why not just use a simple iterator?