Why not create an environment to redefine the .rb environment in rails?

I am trying to work on the Rails site here in its development environment, where I want to check email delivery, and I can’t understand why the properties declared mostly environment.rbare not overwritten by a more specific development.rbfile, which, I believe, will be loaded at boot time rails applications.

My understanding here is that the values ​​in more specific environment configuration files like this should override the general configuration file "environment.rb", so if I declared some email settings, for example, in config/environment.rb...

ActionMailer::Base.smtp_settings = {
  :address        => 'smtp.hostingcompany.com',
  :port           => 25,
  :domain         => 'productiondomain.net',
  :authentication => :login,
  :user_name      => "productiondomainmailer",
  :password       => "TOP_SEKRIT"
}

... then the code here in the config/environments/development.rbbelow should override the hash ActionMailer:Base.smtp_settings:

ActionMailer::Base.smtp_settings = {
  :domain         => 'developmentdomain.net'
}

script/console ActionMailer::Base.smtp_settings[:domain] - "productiondomain.net".

?

 

+3
2

, :

config.action_mailer.smtp_settings =

:

ActionMailer::Base.smtp_settings =

config/environment/development.rb

, config/environment/development.rb , :domain, , .

config/environment.rb, config.action_mailer.smtp_settings = Rails::Initializer.run do |config|.

+2

:

config.action_mailer.smtp_settings = {
  :address        => 'smtp.some_host.com',
  :port           => 25,
  :domain         => 'developmentdomain.net',
  :authentication => :login,
  :user_name      => 'blabla',
  :password       => "some_pass"  
}
+1

Source: https://habr.com/ru/post/1726655/


All Articles