Ruby on rails RoR SendGrid配置错误,不允许部署到Heroku;第10章哈特尔
我在教程中对SendGrid进行了这一点配置,搜索了很多答案,但在尝试推送到heroku时仍然出现以下错误:Ruby on rails RoR SendGrid配置错误,不允许部署到Heroku;第10章哈特尔,ruby-on-rails,heroku,railstutorial.org,sendgrid,Ruby On Rails,Heroku,Railstutorial.org,Sendgrid,我在教程中对SendGrid进行了这一点配置,搜索了很多答案,但在尝试推送到heroku时仍然出现以下错误: NameError: undefined local variable or method `auto' for #<SampleApp::Application:0x007f5c8bdaef78> config/environments.rb中的完整代码: config.action_mailer.raise_delivery_errors = true conf
NameError: undefined local variable or method `auto' for #<SampleApp::Application:0x007f5c8bdaef78>
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
}
非常感谢您的帮助,希望对通过本教程学习的其他人有所帮助。与其将此添加到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"]
}
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"]
}