Rails app使用简单身份验证在Heroku上暂停崩溃环境

时间:2017-11-26 06:24:35

标签: ruby-on-rails rack

你好我的Rails开发人员。那里有架子专家吗?

我已将我的实时应用程序分配到一个专用的临时环境的临时应用程序;我试图根据优秀的" Heroku Cookbook"设置用户名/密码认证。来自Mike Coutermarsh。我在环境文件夹中的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'

我不太确定会发生什么错误。

任何想法都会受到欢迎。

非常感谢!

1 个答案:

答案 0 :(得分:0)

不要在引号中写出类的名称。

config.middleware.use ::Rack::Auth::Basic