Rails Devise confirmable,rememberable
I am very 开发者_开发技巧new to Rails, and got few questions. 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. 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'. I already set config.action_mailer.default_url_options but i still get the error. FYI, reset password does work FINE!
2) Remember_Me checkbox does not take any effect. 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.
3) Does Devise model support user roles? And is it off by default? Any link about how to use Devise User roles will be great!
1) add :confirmable to devise in your User model (user.rb) and restart your server. That will add the user_confirmation_url route for you.
eg. 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. Can you provide more information? Is :timeoutable active? Do these thread help? Devise - remember me not working? LocalHost Issue? 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.
精彩评论