Created
October 15, 2012 16:11
-
-
Save bsimpson/3893334 to your computer and use it in GitHub Desktop.
Using class methods instead of scopes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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