This project is archived and is in readonly mode.
default_url_options is a missing method
-
José Valim
I cannot reproduce this failure on rails master. I just added:
config.action_mailer.default_url_options = { :host => "example.com" }To "config/environments/development.rb" and it worked as expected. Could you provide more information to reproduce the bug?
And the reason we have both :default and :default_url_options it's because they are difference concerns. :default is about your e-mail headers (like :from, :bcc and so on). default_url_options comes from ActionController::UrlFor.
-
trevor
+1
i've run into this too and don't know what the updated API is supposed to be.
after adding
ActionMailer::Base.default_url_options[:host] = "example.com"toapplication.rb-% rails -v Rails 3.0.0.beta % rc /usr/local/lib/ruby/gems/1.9.1/gems/actionmailer-3.0.0.beta/lib/action_mailer/deprecated_api.rb:72:in `method_missing': undefined method `default_url_options' for ActionMailer::Base:Class (NoMethodError) from /usr/local/lib/ruby/gems/1.9.1/gems/actionmailer-3.0.0.beta/lib/action_mailer/base.rb:344:in `method_missing' from /private/tmp/myapp/config/application.rb:7:in `<top (required)>' from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.0.beta/lib/rails/commands.rb:33:in `require' from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.0.beta/lib/rails/commands.rb:33:in `<top (required)>' from /private/tmp/myapp/script/rails:10:in `require' from /private/tmp/myapp/script/rails:10:in `<main>'after adding
config.action_mailer.default_url_options = { :host => "example.com" }toapplication.rb-% rc /usr/local/lib/ruby/gems/1.9.1/gems/actionmailer-3.0.0.beta/lib/action_mailer/deprecated_api.rb:72:in `method_missing': undefined method `default_url_options=' for ActionMailer::Base:Class (NoMethodError) from /usr/local/lib/ruby/gems/1.9.1/gems/actionmailer-3.0.0.beta/lib/action_mailer/base.rb:344:in `method_missing' from /usr/local/lib/ruby/gems/1.9.1/gems/actionmailer-3.0.0.beta/lib/action_mailer/railtie.rb:17:in `block (2 levels) in <class:Railtie>' from /usr/local/lib/ruby/gems/1.9.1/gems/actionmailer-3.0.0.beta/lib/action_mailer/railtie.rb:16:in `each' from /usr/local/lib/ruby/gems/1.9.1/gems/actionmailer-3.0.0.beta/lib/action_mailer/railtie.rb:16:in `block in <class:Railtie>' from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.0.beta/lib/rails/initializable.rb:25:in `instance_exec' from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.0.beta/lib/rails/initializable.rb:25:in `run' from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.0.beta/lib/rails/initializable.rb:55:in `block in run_initializers' from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.0.beta/lib/rails/initializable.rb:54:in `each' from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.0.beta/lib/rails/initializable.rb:54:in `run_initializers' from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.0.beta/lib/rails/application.rb:71:in `initialize!' from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.0.beta/lib/rails/application.rb:41:in `method_missing' from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.0.beta/lib/rails/commands/console.rb:26:in `start' from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.0.beta/lib/rails/commands/console.rb:8:in `start' from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.0.beta/lib/rails/commands.rb:34:in `<top (required)>' from /private/tmp/myapp/script/rails:10:in `require' from /private/tmp/myapp/script/rails:10:in `<main>'this is what http://edgeapi.rubyonrails.org/classes/ActionMailer/Base.html has to say -
When using named routes you only need to supply the :host:<%= users_url(:host => "example.com") %>
You will want to avoid using the name_of_route_path form of named routes because it doesn‘t make sense to generate relative URLs in email messages.
It is also possible to set a default host that will be used in all mailers by setting the :host option in the ActionMailer::Base.default_url_options hash as follows:
ActionMailer::Base.default_url_options[:host] = "example.com"
This can also be set as a configuration option in config/environment.rb:
config.action_mailer.default_url_options = { :host => "example.com" }
(also note the documentation still references config/environment.rb, and should be updated to config/application.rb)
-
Aleksander Kamil Modzelewski
This is a problem in the prerelease, but not in master. Perhaps related to #3857 [PATCH] Rails 3.0 beta ActionMailer::Base.default_url_options not available i...?