Created
March 24, 2015 18:03
-
-
Save step1profit/77a97e52bf07738dc36e to your computer and use it in GitHub Desktop.
Using whatever lib code to modify global config constant in a Ruby on Rails application.rb file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# your_rails_app/config/application.rb | |
# require File.expand_path('../boot', __FILE__) | |
# | |
# Pick the frameworks you want: | |
#require "active_record/railtie" | |
# | |
# [...] | |
# require whatever lib code | |
require "#{File.expand_path('../../lib/whatever.rb', __FILE__)}" | |
# create hash from app config file | |
hash = YAML.load(File.read(File.expand_path('../application.yml', __FILE__))) | |
# overwrite top level vars with env specific vars | |
hash.merge!(hash[Rails.env]||{}) | |
# modify hash with whatever lib code | |
CONFIG = Whatever.something(hash) | |
#module YourRailsApp | |
# class Application < Rails::Application | |
# | |
# [...] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment