缺少主机链接! 请提供:host参数或设置default_url_options (ActionView :: Template :: Error)

我按照建议安装了config.action_mailer.default_url_options = { :host => 'localhost:3000' }并将config.action_mailer.default_url_options = { :host => 'localhost:3000' }到我的development.rb文件中。 当我运行黄瓜时,我收到一个错误:

缺少主机链接! 请提供:host参数或设置default_url_options [:host](ActionView :: Template :: Error)

有谁知道这与什么有关? 谷歌没有太多关于此的信息

Cucumber运行您的测试环境,因此您需要在test.rb添加相同的行。

对于后代,如果它与邮件程序无关,但在运行capybara时仍然会遇到Missing host错误,rspec …

如果您在测试中使用url helpers并且已在rspec配置中包含某个地方:

 config.include Rails.application.routes.url_helpers 

然后,您还应该沿着这一行添加一些东西到同一个配置:

 Rails.application.routes.default_url_options[:host] = "test.host"