Class: Dotenv::Railtie

Inherits:
Rails::Railtie
  • Object
show all
Defined in:
lib/dotenv/rails.rb

Overview

Dotenv Railtie for using Dotenv to load environment from a file into Rails applications

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.loadObject

Rails uses ‘#method_missing` to delegate all class methods to the instance, which means `Kernel#load` gets called here. We don’t want that.



50
51
52
# File 'lib/dotenv/rails.rb', line 50

def self.load
  instance.load
end

Instance Method Details

#loadObject

Public: Load dotenv

This will get called during the ‘before_configuration` callback, but you can manually call `Dotenv::Railtie.load` if you needed it sooner.



37
38
39
# File 'lib/dotenv/rails.rb', line 37

def load
  Dotenv.load(*dotenv_files)
end

#rootObject

Internal: ‘Rails.root` is nil in Rails 4.1 before the application is initialized, so this falls back to the `RAILS_ROOT` environment variable, or the current working directory.



44
45
46
# File 'lib/dotenv/rails.rb', line 44

def root
  Rails.root || Pathname.new(ENV["RAILS_ROOT"] || Dir.pwd)
end