【问题标题】:rails - ActionMailer URL for dev versus prodrails - 开发与生产的 ActionMailer URL
【发布时间】:2010-11-17 06:33:04
【问题描述】:

我一直在本地构建一个应用程序,所有邮件程序都使用了我想要的 URL 0.0.0.0:3000...

现在我刚刚推送到 heroku,并且 URL 没有更新为产品邮件 URL。我设置正确了吗?

/config/environments/production.rb

    config.action_mailer.default_url_options = { :host => 'mynewapp.heroku.com' }

/config/initializers/setup_mail.rb

ActionMailer::Base.smtp_settings = {
  :address              => "smtp.sendgrid.net",
  :port                 => "25",
  :authentication       => "plain",
  :domain               => "xxxxxxx.com",
  :user_name            => "xxxx@xxxxxx.com",
  :password             => "xxxxxxxxxxxxx"
}

# The to field is then changed so that the email is sent to
ActionMailer::Base.default_url_options[:host] = "0.0.0.0:3000"
Mail.register_interceptor(DevelopmentMailInterceptor) if Rails.env.development?

然而所有的 URL 仍然是 0.0.0.0:3000 当我推送到 heroku 以指定 rails 处于生产模式时,我需要设置一些设置吗?还是我在上面搞砸了什么?

谢谢

【问题讨论】:

    标签: ruby-on-rails ruby-on-rails-3 actionmailer


    【解决方案1】:

    把这一行:

    ActionMailer::Base.default_url_options[:host] = "0.0.0.0:3000"
    

    config/environments/development.rb 中,以及在 config/environments/production.rb 中,但在后者中将其修改为适当的 URL。

    通过将其放入初始化程序中,您将其设置为适用于所有环境,这是不正确的。

    【讨论】:

      【解决方案2】:

      将此行添加到您的Gemfile

      gem "action_mailer_auto_url_options"
      

      网址会自动正确映射。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2012-04-03
        • 1970-01-01
        • 2012-01-06
        • 2013-08-19
        • 1970-01-01
        • 2011-12-13
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多