ruby-on-rails - Rails 能够在开发中解析命名空间模型,但不能在暂存环境中解析
问题描述
我在暂存时遇到以下错误,但在本地工作正常。
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
,以便它将从目录顶部解析它。
奇怪的事情:在我的本地/开发环境中,我没有收到错误。
我是在正确地做名称间距/常量的事情还是
- 是因为 Rails 5
auto_reloading
在开发中而不是在登台/生产中还是 - 我是否缺少 config/environments/staging.rb 中的设置
型号/卖家/product.rb
class Seller::Product < ApplicationRecord
...
end
end
模型/seller.rb
class Seller < ActiveRecord::Base
...
end
解决方案
推荐阅读
- angular - 如何在 Angular 5 中使用 sassLoader includePaths?
- r - R - 替换数据框中的 NA
- grep - 管道 psql 错误输出到 grep
- class - 从 Fortran 二进制文件读取错误
- sql - 如何在没有函数的SQL中将字符串拆分为行
- php - PHPUnit 运行动态生成的测试列表
- powershell - 使用 WMI 删除程序后的输出 - Powershell
- python - Python 绝对路径 - 错了吗?
- c - 使用内联函数 c 初始化 const
- javascript - CSS 在使用 webpack 2 的生产环境中不起作用