Invalid delivery method error when trying to add :confirmable to Users in rails

587 Views Asked by At

I added the confirmable attribute to User by following this github wiki https://github.com/plataformatec/devise/wiki/How-To:-Add-:confirmable-to-Users

After that I want sendgrid server to send email confirmation link for that I added an addon in my heroku and do these changes to configure my environment. In my config/environment.rb file I added the following code

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

In my development.rb file I added these two lines

config.action_mailer.delivery_method = :text
config.action_mailer.default_url_options ={:host => 'http://localhost:3000'}

In my production.rb file I added these two lines

config.action_mailer.delivery_method = :smtp
config.action_mailer.default_url_options ={:host => 'finance-tracker-6.herokuapp.com', :protocol => 'https'}

After doing all this.When I am signing up I am getting below error

RuntimeError in Devise::RegistrationsController#create
Invalid delivery method :text
1

There are 1 best solutions below

0
hmnhf On

There's no such delivery method as text. If you don't want to send SMTP emails in development, you can either use the file delivery method to get the emails saved in a file (it's also possible to preview emails), or use something like the letter_opener gem and set the delivery method to letter_opener. With this, emails get displayed in your default browser instead of actually getting sent.