我目前收到以下错误:
1) Organization.invite_user should create a new user for a specific orgs initial user
Failure/Error: organization.invite_user(second_email)
ActionView::Template::Error:
Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true
# ./app/views/devise/mailer/reset_password_instructions.html.erb:5:in `_app_views_devise_mailer_reset_password_instructions_html_erb___4480543240081585515_70131221479860'
# ./app/models/organization.rb:34:in `invite_user'
# ./spec/models/organization_spec.rb:24:in `block (3 levels) in <top (required)>'
任何人都知道在rspec中会发生什么?
答案 0 :(得分:6)
在config / environments / test.rb文件中,您应该提供以下配置:
config.action_mailer.default_url_options = { host: 'www.example.com' }
表示由ActionMailer生成的链接
答案 1 :(得分:2)
错误似乎非常自我解释:您需要向邮件程序初始化程序提供更多信息,以便它知道如何实际呈现链接。
Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true
如果你不这样做,链接必须是亲戚,这在谈论电子邮件中的链接时没有意义。