我有一个模块,其目的是作用于任何给定的ActiveRecord实例。
为了参数的缘故,假设此方法将字符串"match"与某些属性匹配到相同类型的另一个实例。
module Foo
def check_against_other_instances
self.all.each do |instance|
if self.respond_to? :color && self.color == instance.color
puts "match"
end
end
end
end
但是,我不能只是简单地调用self.all这里,因为self是一个实例。我如何all从这里调用类方法?