Skip to content

Instantly share code, notes, and snippets.

@marks
Created April 18, 2009 16:53
Show Gist options
  • Select an option

  • Save marks/97686 to your computer and use it in GitHub Desktop.

Select an option

Save marks/97686 to your computer and use it in GitHub Desktop.
# SELECT * FROM employees
# WHERE ( salary > 10000 )
# AND ( name = 'Jamis' ))
# LIMIT 10
# Will be written as
Employee.with_scope(
:find => { :conditions => "salary > 10000",
:limit => 10 }) do
Employee.find(:all)
Employee.with_scope(
:find => { :conditions => "name = 'Jamis'" }) do
Employee.find(:all)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment