打开 Devise 的确认模块,注册后,会发送确认邮件,但是并不登录。
如何配置 Devise,使得注册后,发送确认邮件,并且网站也是登录状态?
先不说需求,直接说实现:那你就关闭 Devise 的邮件确认,在 User Model 里 after_create 时候调用 Devise 的邮件发送方法就好了。
开启 confirmable devise :database_authenticatable, .... :confirmable
# ==> Configuration for :confirmable
# A period that the user is allowed to access the website even without
# confirming his account. For instance, if set to 2.days, the user will be
# able to access the website for two days without confirming his account,
# access will be blocked just in the third day. Default is 0.days, meaning
# the user cannot access the website without confirming his account.
config.allow_unconfirmed_access_for = nil #2.days