Rails 应用暂存环境在使用简单身份验证的 Heroku 上崩溃
Rails app Staging environment crashing on Heroku with simple authentication
大家好 Rails 开发人员。那里有 Rack 专家吗?
我已将我的实时应用程序分叉到具有专用登台环境的登台应用程序;为此,我正在尝试根据 Mike Coutermarsh 的出色 "Heroku Cookbook" 设置 username/password 身份验证。我在 Environment 文件夹中的 staging.rb 文件如下所示:
# Based on production defaults
require Rails.root.join('config/environments/production')
Jbts2018::Application.configure do
config.middleware.use '::Rack::Auth::Basic' do |user, password|
[user, password] == ['staging', ENV['STAGING_PASS']]
end
end
一旦我将 Heroku 环境设置如下:
RACK_ENV:分期
RAILS_ENV:分期
应用严重崩溃。
Heroku 日志中有趣的部分显示:
2017-11-26T06:08:07.265653+00:00 app[api]: Set RACK_ENV config vars by user
rodolphe@rgeant.name
2017-11-26T06:08:07.265653+00:00 app[api]: Release v63 created by user
rodolphe@rgeant.name
2017-11-26T06:08:08.527577+00:00 heroku[web.1]: State changed from crashed to
starting
2017-11-26T06:08:11.994768+00:00 heroku[web.1]: Starting process with command ` bin/rails server -p 9534 -e staging`
2017-11-26T06:08:15.842600+00:00 heroku[web.1]: State changed from starting to
crashed
2017-11-26T06:08:15.826934+00:00 heroku[web.1]: Process exited with status 1
2017-11-26T06:08:15.765330+00:00 app[web.1]:
/app/vendor/bundle/ruby/2.4.0/gems/actionpack-
5.1.4/lib/action_dispatch/middleware/stack.rb:35:in `build': undefined method ` new' for "::Rack::Auth::Basic":String (NoMethodError)
2017-11-26T06:08:15.765347+00:00 app[web.1]: Did you mean? next
以下代码段中一定有错误:
config.middleware.use '::Rack::Auth::Basic'
虽然我不太确定哪里出了问题。
欢迎提出任何想法。
非常感谢!
不要在引号中写 class 的名称。
config.middleware.use ::Rack::Auth::Basic
大家好 Rails 开发人员。那里有 Rack 专家吗?
我已将我的实时应用程序分叉到具有专用登台环境的登台应用程序;为此,我正在尝试根据 Mike Coutermarsh 的出色 "Heroku Cookbook" 设置 username/password 身份验证。我在 Environment 文件夹中的 staging.rb 文件如下所示:
# Based on production defaults
require Rails.root.join('config/environments/production')
Jbts2018::Application.configure do
config.middleware.use '::Rack::Auth::Basic' do |user, password|
[user, password] == ['staging', ENV['STAGING_PASS']]
end
end
一旦我将 Heroku 环境设置如下:
RACK_ENV:分期 RAILS_ENV:分期
应用严重崩溃。
Heroku 日志中有趣的部分显示:
2017-11-26T06:08:07.265653+00:00 app[api]: Set RACK_ENV config vars by user
rodolphe@rgeant.name
2017-11-26T06:08:07.265653+00:00 app[api]: Release v63 created by user
rodolphe@rgeant.name
2017-11-26T06:08:08.527577+00:00 heroku[web.1]: State changed from crashed to
starting
2017-11-26T06:08:11.994768+00:00 heroku[web.1]: Starting process with command ` bin/rails server -p 9534 -e staging`
2017-11-26T06:08:15.842600+00:00 heroku[web.1]: State changed from starting to
crashed
2017-11-26T06:08:15.826934+00:00 heroku[web.1]: Process exited with status 1
2017-11-26T06:08:15.765330+00:00 app[web.1]:
/app/vendor/bundle/ruby/2.4.0/gems/actionpack-
5.1.4/lib/action_dispatch/middleware/stack.rb:35:in `build': undefined method ` new' for "::Rack::Auth::Basic":String (NoMethodError)
2017-11-26T06:08:15.765347+00:00 app[web.1]: Did you mean? next
以下代码段中一定有错误:
config.middleware.use '::Rack::Auth::Basic'
虽然我不太确定哪里出了问题。
欢迎提出任何想法。
非常感谢!
不要在引号中写 class 的名称。
config.middleware.use ::Rack::Auth::Basic