Right now I\'m using this which works for the development host, but I have to manually change the {:host => \"\"} code when I move to production.
I know this is an old thread, but I ran into this with Ruby 2.6.3 and Rails 5.2.3. The behavior I was seeing was basically that every path I added would fail with Error during failsafe response: undefined method 'empty?' for nil:NilClass. In production it worked fine, but in my development environment, I would get the error mentioned above.
The fix for me was add this to controllers/application_controller.rb:
def default_url_options
if Rails.env.production?
Rails.application.routes.default_url_options = { host: "www.production-domain.com", protocol: 'https' }
elsif Rails.env.development?
Rails.application.routes.default_url_options = { host: 'localhost:3000', protocol: 'http' }
end
end
I was then able to run my development environment on my local.