I'm working through Michael Hartl's ruby on rails tutorial currently looking at email authentications (chapter 11).
I have completed everything in the chapter and everything works perfectly in the development environment but when I push to production with Heroku I get a bug
EXPECTED: after a new user submits the account creation form they should be routed back to the root_url with a flash message asking them to check their email to authenticate
ACTUAL BEHAVIOUR: after a new user submits the account creation form they seem to be routed to /users and there is an error (error reads: we're sorry but something went wrong, please check the logs).
Again this works perfectly in dev, just not in production.
WHAT I HAVE TRIED:
-I checked the logs and can see the email has been generated as expected
-I ran a console in Heroku and can see that the new user was created properly in the database and is has their authenticated field set correctly as false (Waiting for email)
-I can pull the authentication link out of the log and put it in a browser and can see that it authenticates the user properly
-I checked the user model and users controller but can't see any errors (the test suite hopefully would have caught them in dev anyway or the error would have reproduced in dev)
-I reset the heroku database and re-ran migration and db:seed to see if that would help, no change
-I did the push to Heroku again to see if something went wrong there - no change
-I tried deleting the addon in Heroku and reinstalling that, but doing that apparently got my Sendgrid account banned...so I strongly suggest you don't do this. I am now working with Sendgrid to get reactivated.
Attached is the error from the Heroku logs that I could find:
2020-04-08T16:52:25.985006+00:00 app[web.1]: ----==_mimepart_5e8e0149d677d_b2b0ebb83ed445621b--
2020-04-08T16:52:25.985006+00:00 app[web.1]:
2020-04-08T16:52:25.985363+00:00 app[web.1]: I, [2020-04-08T16:52:25.985276 #11] INFO -- : [f4baf186-2987-4d21-bd92-c8324b3a09ca] Completed 500 Internal Server Error in 716ms (ActiveRecord: 6.2ms | Allocations: 5310)
2020-04-08T16:52:25.986654+00:00 app[web.1]: F, [2020-04-08T16:52:25.986541 #11] FATAL -- : [f4baf186-2987-4d21-bd92-c8324b3a09ca]
2020-04-08T16:52:25.986655+00:00 app[web.1]: [f4baf186-2987-4d21-bd92-c8324b3a09ca] Net::SMTPAuthenticationError (535 Authentication failed: account disabled
2020-04-08T16:52:25.986655+00:00 app[web.1]: ):
2020-04-08T16:52:25.986655+00:00 app[web.1]: [f4baf186-2987-4d21-bd92-c8324b3a09ca]
2020-04-08T16:52:25.986656+00:00 app[web.1]: [f4baf186-2987-4d21-bd92-c8324b3a09ca] app/models/user.rb:53:in send_activation_email'
2020-04-08T16:52:25.986656+00:00 app[web.1]: [f4baf186-2987-4d21-bd92-c8324b3a09ca] app/controllers/users_controller.rb:22:increate'
2020-04-08T16:52:25.997396+00:00 heroku[router]: at=info method=POST path="/users" host=afternoon-dawn-31172.herokuapp.com request_id=f4baf186-2987-4d21-bd92-c8324b3a09ca fwd="72.38.16.251" dyno=web.1 connect=0ms service=724ms status=500 bytes=1891 protocol=https
Any help is much appreciated!!!
Attached are the SMTP server settings in case they're the problem?
`
config.action_mailer.delivery_method = :smtp
host = 'afternoon-dawn-31172.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
} `
SENDGRID_USERNAMEandSENDGRID_PASSWORDdefined somewhere?