Is it possible to define custom configuration in config/environments/*.rb or config/environment.rb file.
Is yes, how do i access them from my code (controller, model, library, helper)
Thanks.
Is it possible to define custom configuration in config/environments/*.rb or config/environment.rb file.
Is yes, how do i access them from my code (controller, model, library, helper)
Thanks.
I just use constants. Eg
AWS_PW = "ssss"
you can have different values in the different config files
Access them by their name. They're constants. They're available everywhere--controllers, views, models, etc
# eg
user.pw = AWS_PW
ADDED
Constants need to start with an upper case letter. Usual practice is to use all upper case, underscores, numerals, etc.
You need to restart Rails to pick up the new changes to the environment files since the appropriate environment file is read once.
Note: you can declare a hash as a constant. Eg
# in an environment file...
PARAMS = {}
PARAMS['default_pw'] = 'topsecret!'