【发布时间】:2019-07-25 20:27:56
【问题描述】:
我有一个 Rails 5.2 项目,结构如下:
- 应用/
- 应用程序/身份验证
- app/auth/oauth_controller.rb
- app/auth/oauth.rb
oauth_controller.rb
require_relative "./oauth.rb"
module Auth
class OauthController < Infra::BaseController
include ActionController::Cookies
def start
oauth = Auth::OAuth.new(session: session)
...
end
def callback
oauth = Auth::OAuth.new(session: session)
...
end
end
end
oauth.rb
module Auth
class OAuth
...
end
end
要让Auth::Oauth 工作,我必须要求oauth.rb 文件,所以我认为急切加载或自动加载不起作用。但是,即使使用require(),当我更改文件时,我再次收到此错误,我必须一次又一次地重新启动服务器。
未初始化的常量 Auth::OAuth
这是我的application.rb
config.middleware.use ActionDispatch::Cookies
config.api_only = false
config.eager_load_paths += %W(#{config.root}/app)
config.time_zone = 'Etc/UTC'
config.reload_controllers = !Rails.env.production?
development.rb 没有改变。
【问题讨论】:
标签: ruby-on-rails ruby