Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

undefined method 'join' for nil:NilClass - Rails #155

Closed
chrisjbatts opened this issue Dec 17, 2014 · 5 comments · Fixed by #158
Closed

undefined method 'join' for nil:NilClass - Rails #155

chrisjbatts opened this issue Dec 17, 2014 · 5 comments · Fixed by #158

Comments

@chrisjbatts
Copy link

Followed the instructions on the readme and found an error at the point where the config/application.rb instructs the following:

# config/application.rb
Bundler.require(*Rails.groups)

Dotenv::Railtie.load

Error:

gems/dotenv-rails-1.0.2/lib/dotenv/rails.rb:17:in `load': undefined method `join' for nil:NilClass (NoMethodError)

Rails console and rspec failed to run with the error.

Patched the error by entirely removing:

Dotenv::Railtie.load

and then adding the following inside the rails application module/class:

module RailsAppName
  class Application < Rails::Application
    Dotenv.load Rails.root.join('.env')
  end
end 

Is this a known bug?

@chrisjbatts
Copy link
Author

Also a request for the readme: any time an env variable stored in the .env file is called, the source needs to be wrapped in erb tags. e.g. in secrets.yml:

secret_key_for_something: <%= ENV["abcdefg"] %>

@bkeepers
Copy link
Owner

Yeah, this is a known bug. Rails 4.1ish break Rails.root before the app is initialized.

#144 (comment)

@j-mcnally
Copy link

My work around for now is

Dotenv.load(File.expand_path("../../.env.#{Rails.env}", __FILE__))

@chrisjbatts
Copy link
Author

cheers, will give it a try on the next project - probably about 2 weeks or so

@krishnasrihari
Copy link

Thanks, mcnally code works for me.

Dotenv.load(File.expand_path("../../.env.#{Rails.env}", FILE))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants