Reputation: 2960
eversince I started using Dotenv inside my routes.rb I get weird errors.
I'm using gem 'dotenv-rails', '~> 2.0.0'
routes.rb
:
constraints(host: ENV.fetch("SHORTENER_DOMAIN")) do
get ':id', to: 'shortener#redirect'
end
Terminal:
username:~/Sites/my_app$ rails s
/Users/username/Sites/my_app/config/routes.rb:4:in 'fetch': key not found: "SHORTENER_DOMAIN" (KeyError)
from /Users/username/Sites/my_app/config/routes.rb:4:in 'block in <top (required)>'
username:~/Sites/my_app$ rails s
=> Booting Thin
=> Rails 4.2.5 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
Thin web server (v1.6.4 codename Gob Bluth)
Maximum connections set to 1024
Listening on localhost:3000, CTRL+C to stop
I did not do anything between these two rails s
, just repeated it and it worked. It's really strange.
This is where I'm loading dotenv
:
Bundler.require(*Rails.groups)
Dotenv::Railtie.load
Anyone knows what's happening?
---UPDATE---
I have googled and tried everything. It still appears only in development environment for all rails
, rake
commands.
Has anyone had this problem? It's driving me crazy.
Upvotes: 2
Views: 178