我有以下模块:
module PriceItem
def price_item(mdl, code, opts = {})
gs_collector.do_something()
end
end
这混入了我的 Rails 3.2 应用程序中的一些具有belongs_to :gs_collector关系的模型中。它工作正常。
我还想将此模块混合到 GsCollector 模型中。但这就是我遇到麻烦的地方,因为如果我在上面的示例中更改gs_collector为self,它将不再适用于我混合的其他模型。
我怎样才能在两者中使用它GsCollector,以及具有 的模型belongs_to :gs_collector?