ysets

YAML settings for your Rails 3 app.

Install the gem

Add this to your Gemfile

gem "ysets"

Install with Bundler

bundle install

Adding the YAML file with your key/value pairs

  1. Create a YAML file inside /your_rails_app/config/ysets/ClassName.yml

  2. On your application.rb add

require "ysets/railtie"
module YourApp
  class Application < Rails::Application
    Ysets::Railtie.setup!  
  end
end

YAML file content

You can define key/value pairs in the YAML file and these will be available in your app. You can set the defaults and any environment specific values.

The file must contain each environment that you will use in your Rails app. Here is a sample.yml:

defaults: &defaults
  api_key: asdf12345lkj
  some_number: 999
  erb_stuffs: <%= "erb stuff works" %>
  some_array:
    - element1
    - element2

development:
  <<: *defaults
  api_key: api key for dev

test:
  <<: *defaults

production:
  <<: *defaults

In the above example, you can define the key/value pair using strings, numbers, erb code, or arrays. Notice that the “api_key” in the development environment will override the “api_key” from defaults.

Accessing the values in your Rails app

SAMPLE.api_key # => asdf12345lkj
SAMPLE.some_array[0] # => element1