I have Rails 6.1.0 app:
config.action_mailer.smtp_settings[:password] = AppConfig::Mailchimp.api_key
config/environments/development.rb
module AppConfig
class Mailchimp
def self.api_key
key = ENV['MAILCHIMP_API']
# some additional processing here
# ...
key
end
end
end
app/models/app_config/mailchimp.rb
when trying to run dev console getting:
/config/environments/development.rb:59:in `block in <top (required)>': uninitialized constant AppConfig (NameError)
I'm after migration 6.0.3.4 -> 6.1 and it worked fine for the older Rails version. Apparently they have changed way of loading things in new version, but I'm wondering:
Does anyone know the rationale of that change, any specific reason which brought Rails team to change that or it was not intentional.
How to fix it, I have at least 2 options:
require "#{Rails.root}/app/models/app/app_config/mailchimp"somewhere in theconfig/application.rborconfig/environments/development.rb, but it doesn't look great as bypasses Rails way of booting app- using some built in way of loading config by https://www.rubydoc.org/github/rails/rails/master/ActiveSupport/ConfigurationFile