in , ,

Rails, Devise, Heroku and SendGrid

Here’s the recipe that worked for me to set up  a Rails app with registration using Heroku for hosting and SendGird for emailing.

  • rails g devise:install
  • rails g devise views
  • rails g devise User
  • rake db:migrate
  • heroku create [app name]
  • git add .   then do a git commit -m “something” and finally git push heroku master
  • heroku run rake db:migrate
  • heroku addons:add sendgrid:starter (NOTE: you’ll need a cc on file with heroku to get this to work)
  • update config/environments/production.rb and add this at the bottom:

 

config.action_mailer.default_url_options = { :host => '[your app here].herokuapp.com' }
 ActionMailer::Base.delivery_method = :smtp
  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
  }

At this point, git add and commit again and do another git push heroku master. Keep the ENV[‘SENDGRID_USERNAME’] as it is… that’s an env variable. It will look up your unique send grid add on username and password. DON’T put your real username/pass in there.

If you go to your heroku app /users/sign_up and enter an email and submit, it should make use od the send grid email toolset to send the registration email.

What do you think?

0 points
Upvote Downvote

Total votes: 0

Upvotes: 0

Upvotes percentage: 0.000000%

Downvotes: 0

Downvotes percentage: 0.000000%

Written by Admin

I work for a Telecom company writing and testing software. My passion for writing code is expressed through this blog. It's my hope that it gives hope to any and all who are self-taught.

Comments

Leave a Reply

Loading…

Rails to Heroku: Static Assets

Python Memcache exercise