Skip to content

Instantly share code, notes, and snippets.

@capotej
Created March 14, 2009 23:30
Show Gist options
  • Save capotej/79229 to your computer and use it in GitHub Desktop.
Save capotej/79229 to your computer and use it in GitHub Desktop.
#you can now chain operations by scope
Order.scoped_by_customer_id(12)
Order.scoped_by_customer_id(12).find(:all, :conditions => "status = 'open'")
Order.scoped_by_customer_id(12).scoped_by_status("open")
#Customer is a trillion row table
Customer.find_in_batches(:conditions => {:active => true}) do |customer_group|
customer_group.each { |customer| customer.update_account_balance! }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment