January 23, 2006 20:12
Posted by Jeremy Durham
Ruby/Rails sweetness
Alright, I hate stealing from other people, but I found this on projectionist and HAD to repost it. It’s for generating a “BETWEEN date1 and date2” SQL fragment:
(6.months.ago.to_date..1.year.ago.to_date).to_s(:db)
Which produces:
=> "BETWEEN '2005-07-28' AND '2005-01-23'"
OK, that is seriously too sweet.









0 Comments
Leave a comment