ActionMailer::Base.default_url_options

Hi,

I want so set a default url for ActionMailer. I know,
ActionMailer::Base.default_url_options is deprecated, so I use
config.action_mailer.default_url_options = {
:host => “localhost”
}

in my environments (test.rb, production.rb, …). The problem is, I get
a
deprecation error and rails won’t start. I have no solution…

Any hints for me?

Testing started at 16:31 …
/Users/sebastian/.rvm/gems/ruby-1.9.2-p136/gems/actionmailer-3.0.3/lib/action_mailer/base.rb:763:in
deprecated_url_options': You can no longer call ActionMailer::Base.default_url_options directly. You need to set config.action_mailer.default_url_options. If you are using ActionMailer standalone, you need to include the routing url_helpers directly. (RuntimeError) from /Users/sebastian/.rvm/gems/ruby-1.9.2-p136/gems/actionmailer-3.0.3/lib/action_mailer/base.rb:756:indefault_url_options=’
from
/Users/sebastian/.rvm/gems/ruby-1.9.2-p136/gems/actionmailer-3.0.3/lib/action_mailer/railtie.rb:22:in
block (3 levels) in <class:Railtie>' from /Users/sebastian/.rvm/gems/ruby-1.9.2-p136/gems/actionmailer-3.0.3/lib/action_mailer/railtie.rb:22:ineach’
from
/Users/sebastian/.rvm/gems/ruby-1.9.2-p136/gems/actionmailer-3.0.3/lib/action_mailer/railtie.rb:22:in
block (2 levels) in <class:Railtie>' from /Users/sebastian/.rvm/gems/ruby-1.9.2-p136/gems/activesupport-3.0.3/lib/active_support/lazy_load_hooks.rb:36:ininstance_eval’
from
/Users/sebastian/.rvm/gems/ruby-1.9.2-p136/gems/activesupport-3.0.3/lib/active_support/lazy_load_hooks.rb:36:in
execute_hook' from /Users/sebastian/.rvm/gems/ruby-1.9.2-p136/gems/activesupport-3.0.3/lib/active_support/lazy_load_hooks.rb:43:inblock in run_load_hooks’
from
/Users/sebastian/.rvm/gems/ruby-1.9.2-p136/gems/activesupport-3.0.3/lib/active_support/lazy_load_hooks.rb:42:in
each' from /Users/sebastian/.rvm/gems/ruby-1.9.2-p136/gems/activesupport-3.0.3/lib/active_support/lazy_load_hooks.rb:42:inrun_load_hooks’
from
/Users/sebastian/.rvm/gems/ruby-1.9.2-p136/gems/actionmailer-3.0.3/lib/action_mailer/base.rb:772:in
<class:Base>' from /Users/sebastian/.rvm/gems/ruby-1.9.2-p136/gems/actionmailer-3.0.3/lib/action_mailer/base.rb:333:inmodule:ActionMailer
from
/Users/sebastian/.rvm/gems/ruby-1.9.2-p136/gems/actionmailer-3.0.3/lib/action_mailer/base.rb:9:in
<top (required)>' from /Users/sebastian/Sites/rails/sampleapp/app/mailers/contact_mailer.rb:1:in<top (required)>’
from
/Users/sebastian/.rvm/gems/ruby-1.9.2-p136/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:239:in
require' from /Users/sebastian/.rvm/gems/ruby-1.9.2-p136/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:239:inblock in require’
from
/Users/sebastian/.rvm/gems/ruby-1.9.2-p136/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:227:in
load_dependency' from /Users/sebastian/.rvm/gems/ruby-1.9.2-p136/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:239:inrequire’
from
/Users/sebastian/.rvm/gems/ruby-1.9.2-p136/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:346:in
require_or_load' from /Users/sebastian/.rvm/gems/ruby-1.9.2-p136/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:300:independ_on’
from
/Users/sebastian/.rvm/gems/ruby-1.9.2-p136/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:216:in
require_dependency' from /Users/sebastian/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.3/lib/rails/engine.rb:138:inblock (2 levels) in eager_load!’
from
/Users/sebastian/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.3/lib/rails/engine.rb:137:in
each' from /Users/sebastian/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.3/lib/rails/engine.rb:137:inblock in eager_load!’
from
/Users/sebastian/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.3/lib/rails/engine.rb:135:in
each' from /Users/sebastian/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.3/lib/rails/engine.rb:135:ineager_load!’
from
/Users/sebastian/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.3/lib/rails/application.rb:108:in
eager_load!' from /Users/sebastian/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.3/lib/rails/application/finisher.rb:41:inblock in module:Finisher
from
/Users/sebastian/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.3/lib/rails/initializable.rb:25:in
instance_exec' from /Users/sebastian/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.3/lib/rails/initializable.rb:25:inrun’
from
/Users/sebastian/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.3/lib/rails/initializable.rb:50:in
block in run_initializers' from /Users/sebastian/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.3/lib/rails/initializable.rb:49:ineach’
from
/Users/sebastian/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.3/lib/rails/initializable.rb:49:in
run_initializers' from /Users/sebastian/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.3/lib/rails/application.rb:134:ininitialize!’
from
/Users/sebastian/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.3/lib/rails/application.rb:77:in
method_missing' from /Users/sebastian/Sites/rails/sampleapp/config/environment.rb:5:in<top (required)>’
from
/Users/sebastian/Sites/rails/sampleapp/spec/spec_helper.rb:15:in
require' from /Users/sebastian/Sites/rails/sampleapp/spec/spec_helper.rb:15:inblock in <top (required)>’
from
/Users/sebastian/.rvm/gems/ruby-1.9.2-p136/gems/spork-0.9.0.rc2/lib/spork.rb:23:in
prefork' from /Users/sebastian/Sites/rails/sampleapp/spec/spec_helper.rb:7:in<top (required)>’
from
/Users/sebastian/Sites/rails/sampleapp/spec/controllers/events/contact_messages_controller_spec.rb:2:in
require' from /Users/sebastian/Sites/rails/sampleapp/spec/controllers/events/contact_messages_controller_spec.rb:2:in<top (required)>’
from
/Users/sebastian/.rvm/gems/ruby-1.9.2-p136/gems/rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in
load' from /Users/sebastian/.rvm/gems/ruby-1.9.2-p136/gems/rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:inblock in load_spec_files’
from
/Users/sebastian/.rvm/gems/ruby-1.9.2-p136/gems/rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in
map' from /Users/sebastian/.rvm/gems/ruby-1.9.2-p136/gems/rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:inload_spec_files’
from
/Users/sebastian/.rvm/gems/ruby-1.9.2-p136/gems/rspec-core-2.4.0/lib/rspec/core/command_line.rb:18:in
run' from /Users/sebastian/.rvm/gems/ruby-1.9.2-p136/gems/rspec-core-2.4.0/lib/rspec/core/runner.rb:55:inrun_in_process’
from
/Users/sebastian/.rvm/gems/ruby-1.9.2-p136/gems/rspec-core-2.4.0/lib/rspec/core/runner.rb:46:in
run' from /Users/sebastian/.rvm/gems/ruby-1.9.2-p136/gems/rspec-core-2.4.0/lib/rspec/core/runner.rb:10:inblock in autorun’

Regards,
sewid

Hi,

I just found out, that this problem only occurs, when using
config.cache_classes = true
in my config/test.rb or config/development.rb. If I set it to false,
everything works fine.

Any ideas, why?

Regards and thanks a lot,
sewid