0.0
No commit activity in last 3 years
No release in over 3 years
Based off Mislav's choices gem allows for scoping your configuration
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

>= 0.4.0
 Project Readme

The choice is yours

Easy-peasy external settings for your Rails app.

# Gemfile
gem 'scoped_choices'

In your app initializer block:

# Rails.configuration.my_engine...
config.from_file_with_scope 'settings.yml', "my_scope"

This will read configuration from "config/settings.yml" and, additionally, "settings.local.yml" if it exists. You should check the main file into version control, but not the ".local" file which is to be used for per-machine configuration: tweaks in development or private keys in production, for example.

# .gitignore
config/settings.local.yml

Configuration files can contain ERB; this is useful for reading in Heroku configuration. For example:

# settings.yml
defaults: &defaults
  secret_token: <%= ENV['COOKIE_SECRET'] %>
  heroku: <%= !!ENV['HEROKU_TYPE'] %>
  mongodb:
    uri: <%= ENV['MONGOHQ_URL'] %>

development:
  <<: *defaults

test: &testing
  <<: *defaults
  secret_token: <%= "banana" * 5 %>
  mongodb:
    database: myapp_test

cucumber:
  <<: *testing

The ".local" file can contain overrides for your development environment:

# settings.local.yml
development:
  mongodb:
    database: myapp_dev

Finally, the config keys can be read in your app as such:

Rails.configuration.my_scope.heroku              #=> false
Rails.configuration.my_scope.mongodb.database    #=> "myapp_dev"