【问题标题】:devise mailer_sender production on heroku在 heroku 上设计 mailer_sender 产品
【发布时间】:2013-11-21 15:33:46
【问题描述】:

我已经在 heroku 上部署了我的第一个应用程序。 在开发环境中设计工作正常。

  #/config/initializers/devise.rb
  #on my local machine
  config.mailer_sender = ENV["GMAIL_USERNAME"]

其中 GMAIL_USERNAME 是我的个人电子邮件地址。

在生产中(在 heroku 上)我想使用 sendGrid。 如何使用“用于生产”的设计 mailer_sender 更改当前的设计 mailer_sender? 简单地说:

    config.mailer_sender = info@example.com

如果我使用第二种解决方案,我如何从开发环境发送邮件

我只是有点困惑。

解决方案:

#/config/application.yml
#this file is generated by figaro gem and edited by me.
GMAIL_USERNAME: "xxx@gmail.com"
GMAIL_PASSWORD: "xx"
HOST: "localhost:3000"
SECRET_TOKEN: "dasdasd"

#reconfigure/reset the ENV variables in production environment
production:
  GMAIL_USERNAME: no-reply@example.com
  GMAIL_PASSWORD: #leave blanck to reset it 
  HOST: my-app.heroku.com

【问题讨论】:

    标签: ruby-on-rails heroku devise sendgrid


    【解决方案1】:

    我会使用 Heroku 环境变量来执行此操作:

    在终端:

    heroku config:set GMAIL_USERNAME=info@example.com -a <your production app>

    这样,您的开发配置不会改变(假设您的开发配置中有ENV["GMAIL_USERNAME"]

    【讨论】:

    • 我使用 figaro gem 来管理秘密变量。所以我只想配置config/application.yml。阅读我上面的解决方案。
    猜你喜欢
    • 2012-09-16
    • 2017-02-05
    • 1970-01-01
    • 2023-01-18
    • 1970-01-01
    • 2011-11-27
    • 1970-01-01
    • 2014-07-21
    • 1970-01-01
    相关资源
    最近更新 更多