Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

migration fails on heroku due to activeadmin mailer

I am deploying an app to heroku and the app is on rails 3.2 and I have active admin gem installed.

When I run rake db:migrate it fails due to the following error

    ==  DeviseCreateAdminUsers: migrating =========================================
-- create_table(:admin_users)
   -> 0.0823s

Sent mail to [email protected] (3228ms)
rake aborted!
An error has occurred, this and all later migrations canceled:

Connection refused - connect(2)

Wondering what I need to do to fix this. It seems that the Devise gem or ActiveAdmin needs to send mail during the migration process and because it can't if fails.

like image 257
mattwallace Avatar asked Feb 17 '12 14:02

mattwallace


1 Answers

Try installing the Sendgrid addon:

heroku addons:add sendgrid:starter

If you are deploying to the Aspen or Bamboo stacks, it should work right away. If you are using the Cedar stack, you need to add an additional initializer:

#config/initializers/mail.rb

ActionMailer::Base.smtp_settings = {
  :address        => 'smtp.sendgrid.net',
  :port           => '587',
  :authentication => :plain,
  :user_name      => ENV['SENDGRID_USERNAME'],
  :password       => ENV['SENDGRID_PASSWORD'],
  :domain         => 'heroku.com'
}
ActionMailer::Base.delivery_method = :smtp

Taken from: http://devcenter.heroku.com/articles/sendgrid

like image 129
bruno077 Avatar answered Oct 07 '22 17:10

bruno077