繁体   English   中英

为什么不能通过Devise 3和Rails 4为action_mailer.default_url_options设置主机名?

[英]Why can't I set host name for action_mailer.default_url_options by Devise 3 and Rails 4?

我的config / environments / development.rb文件的某些来源

  config.action_mailer.default_url_options = { :host => 'myapp.apne1.nitrousbox.com' }
  config.action_mailer.delivery_method = :smtp
  config.action_mailer.perform_deliveries = true
  config.action_mailer.default :charset => "utf-8"

  config.action_mailer.smtp_settings = {
    address: "smtp.mandrillapp.com",
    port: 25,
    domain: 'http://myapp.apne1.nitrousbox.com',
    authentication: "plain",
    enable_starttls_auto: true,
    user_name: ENV["MANDRILL_USERNAME"],
    password: ENV["MANDRILL_API_KEY"]
  }

邮件可以成功发送。但是密码重置链接的URL类似于:

https://users/password/edit?reset_password_token=XXXXXXXXXXXXXXXXXX

主机URL myapp.apne1.nitrousbox.com消失了! http变成https

我在互联网上搜索后发现有人遇到了同样的问题,有人很幸运,他们的设置也起作用了,我尝试过但结果相同。


错误日志:

ActionView::Template::Error (Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true):

滑轨

4.1.0

设计

3.4.0

约会时间

AD2014-11-02 00:00:00


[最后一天编辑]

密码重置链接(默认设置):

<%= link_to 'Change password', edit_password_path(@resource, reset_password_token: @token) %>

放:

Rails.application.routes.default_url_options[:host] = "myapp.apne1.nitrousbox.com"

在您的config/production.rb文件中。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM