views:

2240

answers:

3

Hi,

I was wondering how to add custom configuration variables to a rails application and how to access them in the controller, for e.g I wanna be able to define an upload_directory in the configuration files say development.rb and be able to access it in one of my controllers.

Secondly I was planning to have S3 support for uploads in my application, if i wanted to add a yaml file with the s3 access, secret key, how do I initialize it in my Rails App and how do I access the values that I have defined in that config file.

+5  A: 

YAML Configuration File screen cast by Ryan Bates should be very helpful.

khelll
+1 for that railscasts link!
cite
That was really helpful, exactly what I wanted... Thanks!!!
Shiv
A: 

I like to use rails-settings for global configuration values that need to be changeable via web interface.

cite
I dint wanna use additional plugins etc, as I am learning rails, so the best way to do it would be without any plugins.
Shiv
A: 

see my response to http://stackoverflow.com/questions/566333/where-is-the-best-place-to-store-application-parameters-database-file-code/1697933#1697933

Config items are then accessed by referencing the constant variable name (something that threw me for a while ... it was too simple!)

Straff