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?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2007-Dec-08 19:17 UTC
Re: Rails 2.0.1 initializer weird infinite loop situation
On 8 Dec 2007, at 19:03, ptontiger wrote:> > 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 >That''s causing the initializer to be run again from your initializer file, which loads your initializer file, which runs the initializer again ... Fred> # ... > > 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? > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 8 Dec 2007, at 19:03, ptontiger wrote: > > > > > > > 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 > > That''s causing the initializer to be run again from your initializer > file, which loads your initializer file, which runs the initializer > again ... > > Fred > > > # ... > > > 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?--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2007-Dec-08 19:55 UTC
Re: Rails 2.0.1 initializer weird infinite loop situation
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> On Dec 8, 2:17 pm, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: >> On 8 Dec 2007, at 19:03, ptontiger wrote: >> >> >> >> >> >>> 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 >> >> That''s causing the initializer to be run again from your initializer >> file, which loads your initializer file, which runs the initializer >> again ... >> >> Fred >> >>> # ... >> >>> 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? > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Will do. Thanks for the advice. On Dec 8, 2:55 pm, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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 > > > On Dec 8, 2:17 pm, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > wrote: > >> On 8 Dec 2007, at 19:03, ptontiger wrote: > > >>> 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 > > >> That''s causing the initializer to be run again from your initializer > >> file, which loads your initializer file, which runs the initializer > >> again ... > > >> Fred > > >>> # ... > > >>> 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?--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---