Heroku/devise - Missing host to link to! Please provide :host parameter or set default_url_options[:host]

前端 未结 6 2039
南方客
南方客 2020-11-28 01:51

I am trying to push my app on heroku. I am still in dev. I use devise with the confirmable module.

When I try to add a user with the heroku console I got this error:<

6条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-28 02:39

    The working one after so many research,

    1. Don't forget to add default from: mail address in your ApplicationMailer (application_mailer.rb) as,

      class ApplicationMailer < ActionMailer::Base
        default from: 'yourmail@gmail.com'
        layout 'mailer'
      end
      
    2. Add the below configuration in your production.rb.

      config.action_mailer.default_url_options = 
        { :host => 'yourapp.herokuapp.com' }
      config.action_mailer.delivery_method = :smtp
      config.action_mailer.smtp_settings = {
        address:              'smtp.gmail.com',
        port:                 587,
        domain:               'heroku.com',
        user_name:            'yourmail@gmail.com',
        password:             'yourgmailpassword',
        authentication:       'login',
        enable_starttls_auto: true
      }
      
    3. Enable IMAP from your Gmail settings in Forwarding IMAP/POP tab.

    4. Allow less secure apps: ON from https://myaccount.google.com/lesssecureapps

    You're now good to go. :)

提交回复
热议问题