我想通过将共享范围移动到模块中来干燥几个模型,例如:
module CommonScopes
extend ActiveSupport::Concern
module ClassMethods
scope :ordered_for_display, order("#{self.to_s.tableize}.rank asc")
end
end
我还想创建测试模块的共享规范。不幸的是,当我尝试在我的模型中包含共享范围时,我得到:
undefined method `order' for CommonScopes::ClassMethods:Module
有任何想法吗?谢谢!