简体   繁体   English

Rails应用程序不适用于heroku

[英]Rails app not working with heroku

I'm trying to use sendgrid to send confirmation emails to users after they sign up. 我正在尝试使用sendgrid在用户注册后向用户发送确认电子邮件。 Everything was working before I tried configuring send grid, but now as soon as a user tries to sign up, I get the heroku error message to check the logs. 在尝试配置发送网格之前,一切正常,但是现在,一旦用户尝试注册,我就会收到heroku错误消息来检查日志。 I don't know what to make of the logs because every single thing is just a fatal error: 我不知道如何处理日志,因为每件事都是致命错误:

 2016-09-24T02:33:00.151277+00:00 app[web.1]: F, [2016-09-24T02:33:00.151247 #3] FATAL -- : [e27b857c-d6d7-4e1d-a859-0abf408efa52]   vendor/bundle/ruby/2.2.0/gems/actionmailer- 5.0.0.1/lib/action_mailer/message_delivery.rb:96:in `block in deliver_now'
2016-09-24T02:33:00.151307+00:00 app[web.1]: F, [2016-09-24T02:33:00.151277  #3]     FATAL -- : [e27b857c-d6d7-4e1d-a859-0abf408efa52]  vendor/bundle/ruby/2.2.0/gems/actionmailer- 5.0.0.1/lib/action_mailer/rescuable.rb:15:in `handle_exceptions'
2016-09-24T02:33:00.151373+00:00 app[web.1]: F, [2016-09-24T02:33:00.151307 #3] FATAL -- : [e27b857c-d6d7-4e1d-a859-0abf408efa52] vendor/bundle/ruby/2.2.0/gems/actionmailer-5.0.0.1/lib/action_mailer/message_delivery.rb:95:in `deliver_now'
2016-09-24T02:33:00.151406+00:00 app[web.1]: F, [2016-09-24T02:33:00.151374 #3] FATAL -- : [e27b857c-d6d7-4e1d-a859-0abf408efa52] vendor/bundle/ruby/2.2.0/gems/devise-4.2.0/lib/devise/models/authenticatable.rb:191:in `send_devise_notification'

EDIT: Going back in the logs I found these 编辑:回到日志中,我发现了这些

2016-09-  24T05:30:26.437967+00:00 app[web.1]: 
2016-09-24T05:30:26.438280+00:00 app[web.1]: I, [2016-09-24T05:30:26.438213 #3]  INFO -- : [7bde114c-61f1-45c8-9660-f4ce4dc1e7c1] Completed 500 Internal Server Error in 61ms (ActiveRecord: 6.2ms)
2016-09-24T05:30:26.440494+00:00 app[web.1]: F, [2016-09-24T05:30:26.440427 #3] FATAL -- : [7bde114c-61f1-45c8-9660-f4ce4dc1e7c1]   
2016-09-24T05:30:26.440562+00:00 app[web.1]: F, [2016-09-24T05:30:26.440501 #3] FATAL -- : [7bde114c-61f1-45c8-9660-f4ce4dc1e7c1] Errno::ECONNREFUSED (Connection refused - connect(2) for "localhost" port 25):

These are just the first few. 这些只是前几个。 I feel like they're not telling me enough to figure out how to fix the problem. 我觉得他们没有告诉我足够多的方法来解决问题。

The link to the repository if that helps at all: https://github.com/hbrodsk1/facebook 到存储库的链接(如果有帮助的话): https : //github.com/hbrodsk1/facebook

Any guidance would be awesome because I'm truly stuck at this point. 任何指导都是很棒的,因为我确实停留在这一点上。

Have you set your SENDGRID USERNAME and PASSWORD in the rails console through "heroku config:set"? 您是否已通过“ heroku config:set”在rails控制台中设置了SENDGRID USERNAME和PASSWORD? And also including your SENDGRID USERNAME and PASSWORD in your .bashrc file (if you are on c9). 还要在.bashrc文件中包含SENDGRID USERNAME和PASSWORD(如果您使用的是c9)。 Maybe you might like to share what set up procedures you have done for sendgrid? 也许您想分享对sendgrid进行的设置过程?

您必须在heroku配置或rails应用程序的production.rb文件中设置sendgrid用户名和密码。

It looks like you haven't configured the production environment to use Sendgrid for your mailer. 看来您尚未配置生产环境以将Sendgrid用于邮件。 Adding this to your production.rb in the config/environments folder should be the first step. 将此步骤添加到config / environments文件夹中的production.rb中是第一步。 That is as long as you define SENDGRID_USERNAME and SENDGRID_PASSWORD somewhere in the code. 只要您在代码中的某处定义SENDGRID_USERNAMESENDGRID_PASSWORD

config.action_mailer.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 }

This error is coming up because Devise is attempting to handle a mailer event but can't find the instructions on how to process the mailer for the production environment. 由于Devise尝试处理邮件事件,但找不到有关如何在生产环境中处理邮件的说明,因此出现此错误。 You've defined this in the local/development environment already so that's why it works locally. 您已经在本地/开发环境中定义了它,因此这就是它在本地工作的原因。 This should at least point you in the correct direction. 这至少应该为您指明正确的方向。

Check this out as a resource too: https://sendgrid.com/docs/Integrate/Frameworks/rubyonrails.html#-Configure-ActionMailer-to-Use-SendGrid 还将其作为资源进行检查: https : //sendgrid.com/docs/Integrate/Frameworks/rubyonrails.html#-Configure-ActionMailer-to-Use-SendGrid

It turns out that I had to reset my send grid environment username from my console and it worked. 原来,我必须从控制台重置发送网格环境用户名,并且该用户名有效。 Thank you for all of your responses and help though. 谢谢您的所有答复和帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM