Rails: Missing host to link to! Please provide :host parameter or set default_url_options[:host]

前端 未结 15 2678
深忆病人
深忆病人 2020-11-27 10:34

I have been googling for about 90 minutes now and still don\'t have an answer to this. Where do I set default_url_options? I\'ve already set it for conf

15条回答
  •  被撕碎了的回忆
    2020-11-27 11:18

    You need to add the following line at every environment:

    config.action_mailer.default_url_options = { :host => "yourhost" }

    That way, it can work in all environments and could be different from environment to environment. For example:

    development.rb

    config.action_mailer.default_url_options = { :host => "dev.yourhost.com" }
    

    test.rb

    config.action_mailer.default_url_options = { :host => "test.yourhost.com" }
    

    production.rb

    config.action_mailer.default_url_options = { :host => "www.yourhost.com" }
    

提交回复
热议问题