Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

ActionMailer::Base.default_url_options are not actually deprecated

#5749

cfp:/tmp/foo > grep action_mailer config/application.rb

config.action_mailer.default_url_options = {:only_path => false}

cfp:/tmp/foo > ./script/rails generate mailer Mailer

  create  app/mailers/mailer.rb
  invoke  erb
  create    app/views/mailer
  invoke  test_unit
  create    test/functional/mailer_test.rb

cfp:/tmp/foo > ./script/rails runner 'require "action_mailer/version"; p RUBY_VERSION; p Rails::VERSION::STRING; p ActionMailer::VERSION::STRING; p Mailer.default_url_options'
"1.8.7" "3.0.0" "3.0.0" {:only_path=>false}

Reported by ara.t.howard · October 1st, 2010 @ 07:32 PM

State: invalid
Milestone: none
Assigned to: nobody
Importance: Low

Activity

  1. David Trasbo
    David Trasbo
    • State changed from new to invalid
    • Importance changed from to Low

    Yes, default_url_options is not deprecated. Quoting the docs:

    It is also possible to set a default host that will be used in all mailers by setting the :host option as a configuration option in config/application.rb:

    config.action_mailer.default_url_options = { :host => "example.com" }

    Setting ActionMailer::Base.default_url_options directly is now deprecated, use the configuration option mentioned above to set the default host.

    Setting default_url_options through ActionMailer::Base directly is deprecated. Doing it through the standard config object is not.

    October 10th, 2010 @ 04:37 PM

  2. ara.t.howard
    ara.t.howard

    the docs are wrong. this is in an empty rails app.

    cfp:/tmp/app > cat config/initializers/action_mailer.rb
    ActionMailer::Base.default_url_options = {:host => 'dojo4.com'}

    cfp:/tmp/app > ./script/rails runner 'p Rails.version; ActionMailer::Base.default_url_options = {:not => :deprecated}'
    "3.0.0"

    no warning. nada.

    October 11th, 2010 @ 02:37 AM

  3. ara.t.howard
    ara.t.howard

    i've also noticed that only setting ActionMailer::Base.default_url_options has any effect. if you use the config object the options are silently ignored. that will be another bug, however

    October 11th, 2010 @ 02:38 AM

  4. David Trasbo
    David Trasbo

    That is indeed another bug. If the docs state that something is deprecated, it is. Warning or no warning. In this case I think not throwing a warning was chosen because it's technically difficult (or potentially very inelegant) to differentiate between setting through config.action_mailer and ActionMailer::Base since the former basically delegates to the latter.

    That's just my guess. My point is, though, that the docs aren't wrong. Feel free to provide a patch that throws a warning when setting through ActionMailer::Base.

    October 11th, 2010 @ 06:47 PM