Rails Mailer没有接收主机

时间:2016-08-30 15:04:45

标签: ruby-on-rails ruby ruby-on-rails-4

网站位于子目录/app

在development.rb中:

config.action_mailer.default_url_options = {
  host: 'localhost:3000/app'
}

在邮件程序item_url(1)中生成的网址:

localhost/item/1,应该是:localhost:3000/app/item/1

如何将localhost替换为localhost:3000/app

这是在Rails 4.1.15中。

2 个答案:

答案 0 :(得分:1)

要扩展tadman的评论......你的主机应该只有'localhost'部分和一个单独的端口选项:

config.action_mailer.default_url_options = {
  host: 'localhost',
  port: 3000
}

至于在/ app:

下加载应用程序
config.relative_url_root = "/app"

(有关详细信息,请参阅Rails app in a subdirectory

答案 1 :(得分:0)

使用script_name做了诀窍:

config.action_mailer.default_url_options = { 
  host: 'localhost', 
  port: 3000, 
  script_name: '/app' 
}