Ruby on rails 注册计算器在Spree Edge中不再有效?

Ruby on rails 注册计算器在Spree Edge中不再有效?,ruby-on-rails,calculator,spree,Ruby On Rails,Calculator,Spree,在我的主扩展中,我有一个实例化计算器的标准方法。此模块是Spree预初始化过程的一部分: module AgedRevolt class Engine < Rails::Engine config.autoload_paths += %W(#{config.root}/lib) def self.activate Dir.glob(File.join(File.dirname(__FILE__), "../app/**/*_decorator*.rb")

在我的主扩展中,我有一个实例化计算器的标准方法。此模块是Spree预初始化过程的一部分:

module AgedRevolt
  class Engine < Rails::Engine

    config.autoload_paths += %W(#{config.root}/lib)

    def self.activate
      Dir.glob(File.join(File.dirname(__FILE__), "../app/**/*_decorator*.rb")) do |c|
        Rails.env.production? ? require(c) : load(c)
      end

      Calculator::PerWeight.register

    end

    config.to_prepare &method(:activate).to_proc
  end
end
因此,我尝试独立运行它们,并得到以下结果:

app/models/calculator/per_weight.rb:16:in `register': uninitialized constant Calculator::PerWeight::Coupon (NameError)
ruby-1.8.7-p330 :002 > Coupon
NameError: uninitialized constant Coupon
    from (irb):2
ruby-1.8.7-p330 :003 > ShippingRate
NameError: uninitialized constant ShippingRate
    from (irb):3
那是什么原因呢?

我就是这么做的

在我的主要扩展中:

  def self.activate
    Dir.glob(File.join(File.dirname(__FILE__), "../app/**/*_decorator*.rb")) do |c|
      Rails.env.production? ? require(c) : load(c)
    end
    Calculator::PerWeight.register
  end
在我的自定义计算器中:

def self.register
  super
  ShippingMethod.register_calculator(self)
end