Skip to content

Instantly share code, notes, and snippets.

@step1profit
Created March 24, 2015 18:03
Show Gist options
  • Save step1profit/77a97e52bf07738dc36e to your computer and use it in GitHub Desktop.
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
# 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