All threads / Rails for Beginners Part 20: Forgot Your Password Discussion
Ask A Question


You’re not receiving notifications from this thread.

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.

Thanks for your comment, helped me realize that too.


I really these love this series


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

Hi , I hope you have figured it out by now, you have a spelling mistake in POST request - it should be "paSSword' not "paSword".

Join the discussion

Want to stay up-to-date with Ruby on Rails?

Join 66,029+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    logo Created with Sketch.

    Screencast tutorials to help you learn Ruby on Rails, Javascript, Hotwire, Turbo, Stimulus.js, PostgreSQL, MySQL, Ubuntu, and more. Icons by Icons8

    © 2022 GoRails, LLC. All rights reserved.