我已经在谷歌上搜索了大约 90 分钟,但仍然没有答案。我在哪里设置default_url_options?我已经将它设置为config.action_mailer.default_url_options在其他地方解决同样的错误,但是现在我在尝试在 RSpec 规范中使用 URL 帮助程序时遇到了这个错误。我不知道在哪里设置 default_url_options 。
default_url_options
config.action_mailer.default_url_options
Failure/Error: listing_url(listing).should match(/\/\d+-\w+$/) RuntimeError: Missing host to link to! Please provide :host parameter or set default_url_options[:host] # ./spec/routing/listing_routing_spec.rb:9:in `block (3 levels) in <top (required)>'
这段代码与 emails/ActionMailer 无关,只是碰巧需要一个 URL 而不是路径。
有任何想法吗?
Your::Application.routes.draw do default_url_options :host => "example.com" # ... snip ... end
在某处routes.rb:)
routes.rb