我有一个模型,其中我实现了一个返回一组记录的方法。是否可以在 Arel 中推荐它们?
class A < ActiveRecord::Base
#associations here
def self.mymeth
#return a set of records based on a query
B.select(col).joins(:cs).where(some_condition)
end
end
class B < ActiveRecord::Base
#associations here
end
class C < ActiveRecord::Base
#associations here
end
现在我怎么能把 mymeth 引用到类似的东西
A.joins(:mymeth).where(condition).count