Skip to content

Instantly share code, notes, and snippets.

@sagmor
Created July 21, 2011 23:00
Show Gist options
  • Save sagmor/1098439 to your computer and use it in GitHub Desktop.
Save sagmor/1098439 to your computer and use it in GitHub Desktop.
Get an AppConfig file in your app
# This goes to Rails.root/lib
# Requires the hashie gem
::AppConfig = begin
config_file = File.expand_path('../../config/config.yml', __FILE__)
config = Hashie::Mash.new YAML.load_file( config_file )[ Rails.env ]
local_config_file = File.expand_path('../../config/config.local.yml', __FILE__)
if File.exists? local_config_file
config.merge! YAML.load_file( local_config_file )[ Rails.env ] || {}
end
config
end
require File.expand_path('../boot', __FILE__)
require 'rails/all'
# If you have a Gemfile, require the gems listed there, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(:default, Rails.env) if defined?(Bundler)
require File.expand_path('../../lib/app_config', __FILE__) # <-- Here we load the config
module YourApp
class Application < Rails::Application
# Your app config
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment