我在暂存时遇到了以下错误,但在本地工作正常。
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上,我没有收到错误。
我是否正确地使用名称间距/常数或
auto_reloading
但在暂存/生产中没有模型/卖方/ product.rb
class Seller::Product < ApplicationRecord
...
end
end
模型/ seller.rb
class Seller < ActiveRecord::Base
...
end