[Ruby] How to Get Currently Logged-in User ID with User Authentication Engine "Devise"

Tadashi Shigeoka ·  Fri, April 13, 2012

I researched how to get the currently logged-in user ID with the Ruby gem “Devise” that handles user authentication, so here’s a memo.

You can get the currently logged-in user model with current_user.

So, you can get the logged-in user ID by writing it as follows:

current_user.id

That’s all from the Gemba.