Skip to content

Instantly share code, notes, and snippets.

@bsimpson
Created October 15, 2012 16:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bsimpson/3893334 to your computer and use it in GitHub Desktop.
Save bsimpson/3893334 to your computer and use it in GitHub Desktop.
Using class methods instead of scopes
class Foo < ActiveRecord::Base
def self.foo
where("1=1")
end
def self.bar
where("2=2")
end
end
Foo.foo.bar.to_sql # => "SELECT \"foo\".* FROM \"foo\" WHERE (1=1) AND (2=2)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment