ruby - Rails way to write abstracted DateTime calculated SQL condition -


i trying write proper rails abstracted sql statement equivalent to:

select * model date_sub(date_field, interval 7 day) < curdate()

while know can write string sql in rails executed, nice able write in abstract way keeps code database platform agnostic.

it's quite simple, in fact:

model.all( :conditions => [ "date_field between ? , ?", 7.days.ago, date.today ]) 

and have it.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -