I can't remember where I found this idea, but I always create an  
application.yml file in the config directory that's setup just like a  
database.yml file:
development:
   host: localhost
production:
   host: website.com

To load the settings just create an initializer with the following code:
APP_CONFIG = YAML.load(File.read(RAILS_ROOT + "/config/ 
application.yml"))[RAILS_ENV]

Whenever you need to access a setting use:
APP_CONFIG['host']

Hope this helps.

- Nolan

On Oct 31, 2008, at 2:59 PM, Scott Hodson wrote:

>
> I have some settings in my Rails app that are specific to the
> installation/environment it's running in.  Of particular interest, I
> need a separate Google Maps API key that has to be different on each
> domain since the key is tied to the domain the site is running on, and
> I want it decoupled from the source code of the site.
>
> Questions:
> a)    Where should I put these settings?
> b)    What class(es) can I use to retrieve these settings?
>
> In Java I'd put it in a web.xml file, or a .properties file
> In .NET I'd put it in the <appSettings> section of a .config file
> In PHP I'd create a config.php file that I'd have included everywhere
>
> What's the Rails equivalent?  /conf/environment.rb?  Or make some
> .yaml file and put it in /conf?  I want a file that's completely
> specific to the machine/domain/environment it's running under.
>
>
> scott hodson | 949/709-4496 | [EMAIL PROTECTED]
>
> >


--~--~---------~--~----~------------~-------~--~----~
SD Ruby mailing list
[email protected]
http://groups.google.com/group/sdruby
-~----------~----~----~----~------~----~------~--~---

Reply via email to