Created
July 21, 2011 23:00
-
-
Save sagmor/1098439 to your computer and use it in GitHub Desktop.
Get an AppConfig file in your app
This file contains 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
# 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 |
This file contains 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
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