Links
application_config
Categories
application_config
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.
SVN Repository
http://application-config.googlecode.com/svn/
Installation
script/plugin install http://application-config.googlecode.com/svn/tags/application-config
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.
Copyright & License
Copyright © 2008 Pavlo Lysov, released under the MIT license
Vitals
| Home | http://application-config.googlecode.com |
|---|---|
| Repository | http://application-config.googlecode.com/svn/trunk |
| License | Rails' (MIT) |
| Tags |
confiuration
|
| Rating | (12 votes) |
| Owner | Pavlikus |
| Created | 12 June 2008 |
Comments
-
I posted more or less the exact same thing several months ago, except it's a generator rather than a plugin. If you want we could probably find some way to merge them together since I don't think the world needs two separate projects that do almost the exact same thing.
http://randomba.org/index.php/2008/01/03/application-config-generator-for-rails/
-
Thanks. Very useful and POLS plugin.
-
Perfect plugin that does exactly what is needed and makes it in very simple way.
-
I really like this plugin for a simple configuration. My only complaint was that I wanted the YAML file parsed through ERB first so that some of my config settings which are paths can be dynamically determined based and Rails.root and other info. I couldn't find a way to contact the author so I figured I would post my change here:
Change line 9 to the following for ERB processing before loading by YAML:
$__app_config = YAML.load(ERB.new(File.read(config_file)).result binding)

