[Rails] Configuration values
Marcel Molina Jr.
marcel at vernix.org
Wed Jan 5 01:39:05 GMT 2005
On Tue, Jan 04, 2005 at 08:35:59PM -0500, Marcel Molina Jr. wrote:
> On Tue, Jan 04, 2005 at 03:29:36PM -0800, Sean Leach wrote:
> > I read this wiki entry:
> >
> > http://wiki.rubyonrails.com/rails/show/HowtoUseConfigurationFiles
> >
> > and I think I am more confused now about application config variables.
> >
> > I want to have values that are different for development and production,
> > for example
> >
> > @app_config['path']['upload_path']
> > @app_config['main']['prefix']
> >
> > etc. accessible in my controllers, views etc. What is the common way of
> > doing this? i.e. it seems logical I would put this in
> > config/development.yml etc., and there would be a common way to access
> > this information.
<snip>
> The thing that makes this configuration data structure available to you need
> to be a method, per se. You could alternatively make it a CONSTANT.
>
> e.g
>
> APP_CONFIG = YAML.load(File.open(RAILS_ROOT + '/config/development.yml'))
>
> FYI you can't name it Config though as that clashes with a constant set in
> TMail. I'd just stick with a method in any event.
Though one benefit of the constant is that the file just gets loaded
once per request rather than once per config value access.
marcel
--
Marcel Molina Jr. <marcel at vernix.org>
More information about the Rails
mailing list