Anu*_*eek 2 ruby ruby-on-rails devise
我正在使用设计:在我的用户模型中确认.
我的要求是注册/注册后,用户应该成功登录(不经确认),并且确认链接也会发送到用户的电子邮箱.
在第二次如果用户没有确认他的帐户,不应该登录.
如何实现这一目标?
谢谢
为了实现准确你在找什么,你将需要重写设计创造出一些神奇的确认控制器以及该会话控制器.如果您选择沿着这条路走下去,那么在Wiki页面上有许多覆盖Devise控制器的例子.通过启用该:trackable模块,您将sign_in_count可以使用该访问权限进行检查,并且在确认之前只允许使用一个模块.
但是,我想提供一个您可以接受的更简单的解决方案.如果您查看devise.rb 初始化文件,从第122行开始,您将看到您可以在一段时间内允许未经证实的访问您的应用程序.
# ==> 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 = 2.days
Run Code Online (Sandbox Code Playgroud)
我认为最终,从开发人员和最终用户的角度来看,启用此功能并将其设置为可接受的应用程序将是更好的方法.我还要确保在第34行的区域设置中放置一些内容,以便send_instructions在用户必须通过电子邮件确认其帐户之前通知用户他们有x个小时/天的时间来使用该视频.