Rails for Beginners Part 20: Forgot Your Password Discussion
Hi Chris, is there a particular reason the create a different controller for each route action?
I think it is for code modular, in this case I tried to implement reset password and forgot password in the same controller, but I noticed forgot password is not under before_action: needs_logged_in, so I ended up making another controller like the tuto.
I'm at a complete loss as to the difference between Current.user and @user, and when to use which one. Can anyone shed light on that for me? Thanks.
Ahhh. Took a while but I eventually realized that if you forgot your password you aren't logged in, there isn't a session cookie, and Current.user isn't of any use. Duh. :-/
Current.user is a SupportAttribute that helps us to avoid searching our user all the time, he only declares set_current_user( this method assigns the value of Current.user), but with SupportAttribute, this variable is converted into a global variable.
Thank you very much, Chris! I'm learning a lot. It doesn't feel like it's only an 8 min video. You can deliver a huge amount of useful information in a few minutes.
I'm getting a
Routing Error
No route matches [POST] "/password/reset" when I click on the reset password button. I can see that I do have the route.
1)password_reset GET /password/reset(.:format) password_resets#new
2)pasword_reset POST /pasword/reset(.:format) password_resets#create