Ruby LoadError(无法自动加载常量错误::ErrorHandler
我正在尝试为整个应用程序构建错误模块Ruby LoadError(无法自动加载常量错误::ErrorHandler,ruby,ruby-on-rails-5,Ruby,Ruby On Rails 5,我正在尝试为整个应用程序构建错误模块 config.eager_load_paths << Rails.root.join('lib') 我已将此模块包含在ApplicationController中 include Error::ErrorHandler 但每当我尝试点击任何错误时,控制台就会抛出 LoadError (Unable to autoload constant Error::ErrorHandler, expected /Users/username/path/l
config.eager_load_paths << Rails.root.join('lib')
我已将此模块包含在ApplicationController中
include Error::ErrorHandler
但每当我尝试点击任何错误时,控制台就会抛出
LoadError (Unable to autoload constant Error::ErrorHandler, expected /Users/username/path/lib/error/error_handler.rb to define it):
Error during failsafe response: Unable to autoload constant Error::ErrorHandler
有人能帮我吗?谢谢,你也需要把它添加到
config.autoload\u路径中。@fyloi我也尝试过添加config.autoload\u路径。但是结果是一样的。另外,error\u handler.rb
需要在/lib/error/
@fyloi我提到error\u handler.rb在lib/error/directory添加中config.autoload_path+=Dir[“#{Rails.root}/lib”]
和服务器重启总是对我有用。我不知道你为什么会遇到错误。你是在应用程序.rb发生更改后重新启动服务器的吗?你也需要将它添加到config.autoload\u路径中。@fyloi我也尝试过添加config.autoload\u路径。但是结果是一样的。另外,error\u handler.rb
需要在/lib/error中/
@fylooi我已经提到error_handler.rb在lib/error/directoryaddingconfig.autoload_paths+=Dir[“{Rails.root}/lib]”中,服务器重启对我来说总是有效的。我不知道你为什么会遇到错误。你在application.rb发生更改后重启了服务器吗??
LoadError (Unable to autoload constant Error::ErrorHandler, expected /Users/username/path/lib/error/error_handler.rb to define it):
Error during failsafe response: Unable to autoload constant Error::ErrorHandler