Class: EnvJson::Railtie

Inherits:
Rails::Railtie
  • Object
show all
Defined in:
lib/env_json/railtie.rb

Overview

Rails hook to autoload ENV from JSON file before configuration

Instance Method Summary collapse

Instance Method Details

#load_envObject

railtie hook to load env with Rails.env as environment name and config/env.json files as source



7
8
9
10
11
12
# File 'lib/env_json/railtie.rb', line 7

def load_env()
  env_json_file = Rails.root.join('config/env.json')
  environment_name = Rails.env
  puts "EnvJson: file #{env_json_file} does not exists" && return unless File.exist? env_json_file
  EnvJson.load_env_from_source_with_overrides(env_json_file, environment_name)
end