How to run rails console as an authenticated devise user without knowing the password

I maintain a few rails apps for my clients (running in production). And sometimes certain bugs occur only for specific users. There are two ways to debug these issues:

Get the user to show you how the bug occurs

Try it out by signing into the site as that user

Now option 2 isn’t practical as your users don’t want to share their passwords with you. What I do to get around this fact is test the user interface through rails console in production. Now, we use devise for authentication so it wasn’t so hard to sign in as the desired user. All you need to run in your production rails console is:

12345

classUserdefvalidate_password?(pwd)trueendend

where User is your devise model. Now to signin as the desired user (foo@mailinator.com) from the console you run