【问题标题】:RoR SendGrid error in configuration, will not allow deploy to Heroku; Ch 10 HartlRoR SendGrid 配置错误,不允许部署到 Heroku;第 10 章
【发布时间】:2015-10-15 15:11:22
【问题描述】:

我已经按照教程对 SendGrid 进行了一些配置,搜索了很多答案,但在尝试推送到 heroku 时仍然出现此错误:

NameError: undefined local variable or method `auto' for #<SampleApp::Application:0x007f5c8bdaef78>

抛出错误的那一行:

:enable_starttls_auto => true

来自 config/environments.rb 的完整代码:

  config.action_mailer.raise_delivery_errors = true
  config.action_mailer.delivery_method = :smtp
  host = 'gentle-sands-4285.herokuapp.com'
  config.action_mailer.default_url_options = { host: host }
  ActionMailer::Base.smtp_settings = {
    :address        => 'smtp.sendgrid.net',
    :port           => '587',
    :authentication => :plain,
    :user_name      => ENV['SENDGRID_USERNAME'],
    :password       => ENV['SENDGRID_PASSWORD'],
    :domain         => 'heroku.com',
    :enable_starttls_auto => true
  }

非常感谢任何帮助,希望对通过本教程学习的其他人有所帮助。

【问题讨论】:

    标签: ruby-on-rails heroku railstutorial.org sendgrid


    【解决方案1】:

    不要将此添加到您的 config/environment.rb 文件中,而是尝试将其添加到您的 config/environments/ 文件夹中的文件中。这是我所做的:

    我将此添加到我的 config/environments/production.rb:

      config.action_mailer.default_url_options = { :host => 'YOUR_APP.herokuapp.com' }
    
      config.action_mailer.delivery_method = :smtp
      config.action_mailer.perform_deliveries = true
      config.action_mailer.raise_delivery_errors = false
      config.action_mailer.default :charset => "utf-8"
    
      config.action_mailer.smtp_settings = {
        address: ENV["SMTP_ADDRESS"],
        port: 587,
        domain: ENV["EMAIL_DOMAIN"],
        authentication: "plain",
        enable_starttls_auto: true,
        user_name: ENV["EMAIL_USERNAME"],
        password: ENV["EMAIL_PASSWORD"]
      }
    

    这是我的 config/environments/development.rb:

    config.action_mailer.default_url_options = { :host => 'localhost:3000' }
      config.action_mailer.delivery_method = :smtp
      config.action_mailer.smtp_settings = {
        address: ENV["SMTP_ADDRESS"],
        port: 587,
        domain: ENV["EMAIL_DOMAIN"],
        authentication: "plain",
        enable_starttls_auto: true,
        user_name: ENV["EMAIL_USERNAME"],
        password: ENV["EMAIL_PASSWORD"]
      }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-08-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-07-09
      • 2013-07-18
      相关资源
      最近更新 更多