这是我的用户模型。
class User < ApplicationRecord
# Include default devise modules. Others available are:
# :timeoutable, :trackable and :omniauthable
devise :database_authenticatable, :registerable, :recoverable, :rememberable, :validatable
end
我应该如何配置devise在用户注册时发送确认邮件?
对于生产,你需要配置一个第三方的邮件发送服务,比如sendgrid。例如:在heroku.com上注册。
heroku create
heroku rename your-app-name
git push heroku master
heroku run rake db:migrate
heroku addons:create sendgrid:starter
环境.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',
:enable_starttls_auto => true
}
production. rb:
config.action_mailer.default_url_options = { :host => 'your-app-name.herokuapp.com', :protocol => 'https' }
config.action_mailer.perform_deliveries = true
config.action_mailer.delivery_method = :smtp
这样你就可以在生产中发送接收所有的devise邮件了。