A simple Rails plugin that eases project configuring by introducing erb enabled yaml config file in RAILS_ROOT/config folder and provides handful methods accessing config values based on current rails environment
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib
test
.gitignore
Gemfile
MIT-LICENSE
README.rdoc
Rakefile
application_config.gemspec

README.rdoc

application_config functionality

'application_config' eases project configuring by introducing erb enabled yaml config file in RAILS_ROOT/config folder and provides handful methods accessing config values based on current rails environment. So, you can have separate sets of configuration properties for each rails environment you use.

Installation

gem “cleverua_application_config”, “~> 2.0”, :require => “application_config”

Then run:

rails generate application_config:install

Default configuration file

During installation plugin will create default config in RAILS_ROOT/config/application_config.yml, it looks like the following (please note it's okay to put ERB tags in there)

development: &defaults
  items_per_page: 25
  secure_with_basic_auth: false
  base_url: development.com
  erb_enabled_property: <%= "#{Rails.root}/something" %>
test:
  <<: *defaults
  base_url: test.com
production:
  <<: *defaults
  base_url: production.com

Usage

You then can access those values using 'property' method:

class FooController < ApplicationController
  def index
    @base_url = property(:base_url)
  end
end

This will set @base_url with value 'development.com' if you run that in development environment.