Rails 2.0.1 initializer weird infinite loop situation

Just switched an app over from 1.2 to 2.0.
In accordance with the new convention, I moved my custom configuration
information out of config/environment.rb and into config/initializers/
app_config.rb. I found that my actionmailer config block was causing
an infinite loop (encompassing more than just the block itself).
Nothing like this happened with 1.2.x. Here’s the code (nothing
special):

DOMAIN_NAME = ‘example.com

Uses lib/smtp_tls.rb (Gmail SSL SMTP requires this)

Rails::Initializer.run do |config|
config.action_mailer.perform_deliveries = false # For now

config.action_mailer.perform_deliveries = true

config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.default_charset = :‘utf-8’
config.action_mailer.smtp_settings = {
:address => ‘smtp.gmail.com’,
:port => 587,
:domain => DOMAIN_NAME,
:authentication => :plain,
:user_name => ‘mailer@’ + DOMAIN_NAME,
:password => ‘secret’
}
end

As is, Rails won’t load and a never ending train of warnings about an
already initialized constant DOMAIN_NAME shows in the console
(evidence that the infinite loop encompasses more than the block). lib/
smtp_tls.rb is not the source of the problem and neither is the
declaration of the constant.

There are two ways to fix this as far as I know - comment out the
block and skip the configuration or put ‘break’ before ‘end’.

Any ideas on what’s behind this?

On 8 Dec 2007, at 19:03, ptontiger wrote:

:domain => DOMAIN_NAME,
:authentication => :plain,
:user_name => ‘mailer@’ + DOMAIN_NAME,
:password => ‘secret’
}
end

That’s causing the initializer to be run again from your initializer
file, which loads your initializer file, which runs the initializer
again …

Fred

Thanks Fred, that makes perfect sense. That being the case, how would
I inject this configuration information into the mix then?

On Dec 8, 2:17 pm, Frederick C. [email protected]

On 8 Dec 2007, at 19:22, ptontiger wrote:

Thanks Fred, that makes perfect sense. That being the case, how would
I inject this configuration information into the mix then?

I think that sort of stuff is fine to stay in environment.rb -
basically it’s not about
extracting stuff from the Rails::Initializer.run do |config| block but
about all the stuff at the bottom.

Fred

Will do. Thanks for the advice.

On Dec 8, 2:55 pm, Frederick C. [email protected]