为什么测试环境需要为ActionMailer设置default_url_options?Rails测试环境:为什么它需要ActionMailer的default_url_options?
ActionView::Template::Error:
Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true
在电子邮件设置
config.action_mailer.default_url_options = {host: 'localhost:3000'}
然后在理论上链接,因为当我特别想知道:
如果我不设置它,我执行我的规格时,得到这个会导致localhost:3000,据我所知,这不是测试服务器实例运行的地方?尽管如此,使用email_spec
宝石,点击电子邮件中的链接时,他们的工作,因为创业板中删除服务器名称和端口,这样的链接通常是这样的:
/en/user/confirmation?confirmation_token=QZu3tw17uozhpEfuVWzF
所以一次:我需要什么指定主机是否被email_spec
宝石去掉了?
[准备URL]时引发异常(https://github.com/rails/rails/blob/c8bd12cf5a1dc7ebdb1594334b2598d799d4a746/actionpack/lib/action_dispatch/http/url.rb#L63) – 2015-03-31 16:56:49