Rails能够在开发中解析命名空间模型,但不能在登台环境

时间:2018-06-07 05:45:33

标签: ruby-on-rails ruby ruby-on-rails-5

我在暂存时遇到了以下错误,但在本地工作正常。

NameError (uninitialized constant Manager::Seller::Product)

/app/services/manager/admins/sellers/products/curation.rb

中的行导致错误
module Manager
  module Admins
    module Sellers
      module Products
         class Curation
            ...
            def my_function
               @product.update(entity_id: @entity_id,
                               curation_status: Seller::Product.curation_statuses[:accepted])
             end
      ....

通过在上面的代码中将::附加到Seller::Product,使其成为绝对值,这样就可以从目录顶部解析它。

奇怪的是:在我的本地/ dev env上,我没有收到错误。

我是否正确地使用名称间距/常数或

  • 是否导致Rails 5在开发中具有auto_reloading但在暂存/生产中没有
  • 我在config / environments / staging.rb
  • 中缺少设置

模型/卖方/ product.rb

  class Seller::Product < ApplicationRecord
      ...
  end
end

模型/ seller.rb

class Seller < ActiveRecord::Base
   ...
end

参考:http://guides.rubyonrails.org/autoloading_and_reloading_constants.html#autoload-paths-and-eager-load-paths

0 个答案:

没有答案