DEV Community

Discussion on: Easier usage of Rails 5.2 credentials and app-specific configuration

Collapse
 
prabakaran1993 profile image
Praba

Thanks @Leonid for this wonderful approach for handling configurations.

I faced a problem in extending this approach to an already existing project.

Scenario:

  • There were existing config.x nested attributes in env specific files (eg: development.rb)
  • Defining self.config method in application.rb disrupts the default config.x class and thus affects the behaviour in other files (because now the config.x will be an instance of Hash/with_indifferent_access)
  • Also after defining the self.config, we will loose existing config. values

I worked around it by adding the following method.

config_for(:app).each do |key, val|
  config.send("#{key}=", val)
end

So that the existing behaviours is not disturbed.
Also I believe it's advised to use config.x only for nested attributes.