Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.