Q:

Ruby dotenv gem not loading .env file

I have the both the dotenv and dotenv-rails gem installed in my project. When I run the rails console I can type:  
2.4.0 :001 > ENV["DATABASE_NAME"]
 => "portfolio_site_development"

However my problem arises with Ruby, when in a Ruby file or the irb terminal when I call:   
2.4.0 :001 > ENV["DATABASE_NAME"]
 => nil 

I am requiring dotenv in my Ruby file. What am I doing wrong?

A:

Okay I figured it out. While this used to work, I guess a recent update of dotenv has changed things.
Because my ruby script is located in ./lib/scripts/script.rb I needed to call Dotenv.load("../../.env") so that it would point it to my .env file in the root of the project structure.

