简体   繁体   English

Rails设计可确认,可记住

[英]Rails Devise confirmable,rememberable

I am very new to Rails, and got few questions. 我对Rails很新,并且几乎没有问题。 Will be very pleased if somebody helps me to figure out with my problems(please answer if you know even answer to one of the questions ) 1) I am using Devise gem for user authentication. 如果有人帮助我解决我的问题,请非常高兴(如果您知道甚至回答其中一个问题,请回答)1)我正在使用Devise gem进行用户身份验证。 Now i want to activate confirmable, so user should confirm via email. 现在我想激活确认,因此用户应通过电子邮件确认。 Whatever i do, i keep on getting the following error - undefined method `user_confirmation_url'. 无论我做什么,我继续得到以下错误 - 未定义的方法`user_confirmation_url'。 I already set config.action_mailer.default_url_options but i still get the error. 我已经设置了config.action_mailer.default_url_options但我仍然收到错误。 FYI, reset password does work FINE! 仅供参考,重置密码确实有效!

2) Remember_Me checkbox does not take any effect. 2)Remember_Me复选框不起任何作用。 I tick the checkbox but when i close the browser and open it again it still asks me to be authenticated. 我打勾复选框,但当我关闭浏览器并再次打开它时,它仍然要求我进行身份验证。 I set config.remember_for = 15.minutes and did NOT set any time out, but it still asks to login. 我设置config.remember_for = 15.minutes并没有设置任何超时,但它仍然要求登录。

3) Does Devise model support user roles? 3)Devise模型是否支持用户角色? And is it off by default? 它是默认关闭的吗? Any link about how to use Devise User roles will be great! 任何关于如何使用Devise用户角色的链接都会很棒!

1) add :confirmable to devise in your User model (user.rb) and restart your server. 1)添加:确认您的用户模型(user.rb)并重新启动服务器。 That will add the user_confirmation_url route for you. 这将为您添加user_confirmation_url路由。

eg. 例如。 in user.rb devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable, :omniauthable, :confirmable in user.rb devise:database_authenticatable,:registerable,:recoverable,:rememberable,:trackable,:validatable,:omniauthable,:confirmable

You need to also add confirmable to your migration file as well to make it work. 您还需要在迁移文件中添加确认信息以使其正常工作。

2) Not sure. 2)不确定。 Can you provide more information? 你能提供更多信息吗? Is :timeoutable active? 是:超时有效吗? Do these thread help? 这些线程有帮助吗? Devise - remember me not working? 设计 - 还记得我不工作吗? LocalHost Issue? LocalHost问题? Devise Remember Me and Sessions 设计记住我和会话

3) Devise roles: https://github.com/plataformatec/devise/wiki/How-To:-Add-an-Admin-role Depending on what you are looking for, cancan ( https://github.com/ryanb/cancan ) or acl9 ( https://github.com/be9/acl9 ) may be better. 3)设计角色: https//github.com/plataformatec/devise/wiki/How-To :-Add-an-Admin-role根据您的需求,cancan( https://github.com/ryanb) / cancan )或acl9( https://github.com/be9/acl9 )可能会更好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM