Hello my fellow Rails developers. Any Rack specialist out there?
I have forked out my live app to a staging app whith a dedicated staging environment; for which I’m trying to setup a username/password authentication as per the excellent “Heroku Cookbook” from Mike Coutermarsh. My staging.rb file in the Environment folder looks like:
# 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
As soon as I set the Heroku Environment as follows:
RACK_ENV: staging RAILS_ENV: staging
the app crashes miserably.
From the Heroku logs the interesting bits show:
2017-11-26T06:08:07.265653+00:00 app[api]: Set RACK_ENV config vars by user email@example.com 2017-11-26T06:08:07.265653+00:00 app[api]: Release v63 created by user firstname.lastname@example.org 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
There must be some error in the following snippet :
I’m not too sure what’s wrong though.
Any idea will be most welcome.