Skip to content

Instantly share code, notes, and snippets.

@joeljunstrom
Created November 24, 2010 23:19
Show Gist options
  • Save joeljunstrom/714619 to your computer and use it in GitHub Desktop.
Save joeljunstrom/714619 to your computer and use it in GitHub Desktop.
class Account < ActiveRecord::Base
scope :scope1, where("domain in('bit', 'bite')")
scope :scope2, where("custom_domain = 'bites'")
end
>> Account.scope1.scope2.to_sql
=> "SELECT \"accounts\".* FROM \"accounts\" WHERE (domain in('bit', 'bite')) AND (custom_domain = 'bites')"
>> Account.scope2.scope1.to_sql
=> "SELECT \"accounts\".* FROM \"accounts\" WHERE (custom_domain = 'bites') AND (domain in('bit', 'bite'))"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment