bkeepers / dotenv

A Ruby gem to load environment variables from `.env`.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Question about Dotenv.load

coding-bunny opened this issue · comments

If I use Dotenv.load in a plain Ruby app, will it also load automatically other files if I have them defined and the RAILS_ENV variable set? Or do I need to manually load them?

Short answer: you have to manually load them.

Long answer:
If you want the rails behaviour, you would have to do require 'dotenv/rails' which would not work or just raise an exception unless you're using rails. The reason for this is that dotenv hooks itself into the rails plugin pipeline.

Okay, then I did it right!

We copied the logic of the rails loader and just load them ourselves in the correct order.
Thanks for the clarification.