Rails 3 w/ Devise:如果用户尚未确认电子邮件地址,如何在所有页面上显示消息?
我正在开发一个 Rails 3 应用程序,使用 Devise gem 进行身份验证。我还使用 Devise 的可确认模块在用户注册时向他们发送电子邮件,要求他们确认他们的电子邮件地址。
我允许用户登录,即使他们没有确认自己的电子邮件地址(最多 20 天),但是我想在每个页面的顶部显示一条消息,提醒他们没有确认自己的电子邮件地址,并且他们仍然可以在 X 天不这样做的情况下登录。
我应该如何处理这个问题有什么想法吗? (即任何有用的宝石或提示)
非常感谢!
I am developing a Rails 3 app using the Devise gem for authentication. I'm also using the confirmable module of Devise to send emails to users when they sign up, asking them to confirm their email address.
I am allowing users to sign in even if they didn't confirm their email address (for a maximum of 20 days), however I want to display a message at the top of every page reminding them they didn't confirm their email address and that they can still login without doing so for X number of days.
Any ideas of how I should approach this? (i.e. any useful gems or tips)
Thanks very much !!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
查看此处的文档: http://rubydoc.info/github/plataformatec /devise/master/Devise/Models/Confirmable
似乎有一个
confirmed?
方法,您可以在 User 对象上调用该方法来查看它们是否已确认。因此,我只需在您的
views/layouts/application.html.erb
文件中检查确认情况:Looking at the docs here: http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Confirmable
It seems there is a
confirmed?
method that you can call on the User object to see if they are confirmed or not.So I would just put a check for the confirmation in your
views/layouts/application.html.erb
file: