Last active
December 10, 2015 10:19
-
-
Save LolWalid/94e8d6b731be8369db55 to your computer and use it in GitHub Desktop.
Class methods apply to collection - Ruby
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 MyModel < ActiveRecord::Base | |
scope :custom_scope, -> { where.not(id: [1, 2, 3]) } # id not in (1, 2, 3) <=> id != 1 and id != 2 and id != 3 | |
def self.class_method | |
all.each { |x| puts x } | |
end | |
def to_s | |
'Hey' | |
end | |
end | |
MyModel.custom_scope.class_method |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment