Ruby on Rails Devise Controller Filters & Helpers


Example

To set up a controller with user authentication using devise, add this before_action: (assuming your devise model is 'User'):

before_action :authenticate_user!

To verify if a user is signed in, use the following helper:

user_signed_in?

For the current signed-in user, use this helper:

current_user

You can access the session for this scope:

user_session

  • Note that if your Devise model is called Member instead of User, replace user above with member