config.scoping == :important => true
Chris Brandhorst ma 01 mrt 10
Last week I realised that using the config scope in your Rails environment files can be quite important.
We had the situation that we needed a different SMTP configuration for different environments.
In the environment.rb I found the following lines:
Rails::Initializer.run do |config| ... end ActionMailer::Base.smtp_settings = { :address => "127.0.0.1", :port => 25, :domain => "hollandonrails.nl" }
For the develoment environment I needed something else, so I proceeded to add the following to development.rb:
ActionMailer::Base.smtp_settings = { :address => "mail.google.com", :port => 25, :domain => "bla.com" }
But then the emails were not sent in the dev environment. Not knowing the cause, I spent an hour or two figuring this out.
Finally, I found out that the ActionMailer settings given in development.rb were not used. Some more investigation revealed the following things:
- ActionMailer is not defined within the Rails::Initializer block in environment.rb
- Using ActionMailer inside development.rb does NOT raise an error, but the scope of development.rb seems to be the same Rails::Initializer block
- Setting ActionMailer settings using config.action_mailer (like below) does allow overriding of these settings
config.action_mailer.smtp_settings = { :address => "127.0.0.1", :port => 25, :domain => "hollandonrails.nl" }
Gepost in | 0 reacties
Welkom op Holland On Rails
Het startpunt voor Ruby On Rails in Nederland. Vind de laatste technieken, meningen en nieuwtjes.Recente Jobs
Gezocht: Ruby On Rails ontwikkelaar (junior of senior)
Eet, drink en droom jij over Ruby On Rails? Wil jij het liefste dag en nacht bezig zijn met jehobby; super coole webapplicaties ontwikkelen in Ruby On Rails?
Dan willen wij jou graag een podium bieden om je Ruby skills te vertonen aan onze nationale en internationale klanten!
@ Internetbureau Holder, Obdam
Bekijk alle jobs »»
Gereedschapskist
Onmisbare tools vooriedere developer!
- Ruby On Rails
Framework voor de web 2.0 developer. Eindelijk vooruitgang! - TextMate
Editor for true pro's
Typ, tab, top :-)
Nee, niet voor Win. - Made On A Mac
En nou is het over met die saaie grijze Windows bak van je!
Auteurs op deze site
Chris Obdam
'Less is more' evangelist, past dit ook dagelijks toe op zijn tandenborstel.Chiel Wester
Snelheidswonder op Ruby wielen. Leuk om mee te pair-programmen ;-)
Plaats je reactie