Created
December 11, 2011 18:51
-
-
Save igor-alexandrov/1462080 to your computer and use it in GitHub Desktop.
Multiple configuration files in SettingsLogic
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
class Settings < Settingslogic | |
source "#{Rails.root}/config/application.yml" | |
if Rails.env == 'development' | |
namespace 'development-' + Socket.gethostname.gsub(/\W/, '-').gsub(/[-]{2,}/, '-') | |
else | |
namespace Rails.env | |
end | |
# load local settings | |
begin | |
hash = YAML.load(ERB.new(File.read("#{Rails.root}/config/application_local.yml")).result)[Rails.env] | |
instance.deep_merge!(hash) | |
rescue => e | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Additionally, I think you should also remember to define the
reload!
method so we can ensure local settings will be keep loaded though user have refresh settings fromapplication.yml
. The version after refactor will be like: