Skip to content

Instantly share code, notes, and snippets.

@dnch
Forked from cherring/gist:117876
Created May 26, 2009 03:57
Show Gist options
  • Save dnch/117880 to your computer and use it in GitHub Desktop.
Save dnch/117880 to your computer and use it in GitHub Desktop.
# named_scope :between, lambda {|start_date, end_date, field|
# { :conditions => ["\"#{field}\" >= ? AND \"#{field}\" <= ?", start_date, end_date] }
# }
From the docs...
A range may be used in the hash to use the SQL BETWEEN operator
Student.find(:all, :conditions => { :grade => 9..12 })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment