Eric Baldwin
Eric Baldwin

Reputation: 3491

Using current_user and other Devise Helpers in the rails console

I want to call current_user in the rails console to ensure a user is logged in. When I write it though, I get the following error:

1.9.3p393 :045 > current_user
NameError: undefined local variable or method `current_user' for main:Object

How do I include the appropriate module that would let me use this method?

Upvotes: 2

Views: 2100

Answers (1)

user2297081
user2297081

Reputation: 56

Best thing would be to use pry gem. Once you install it, just add the line pry to your controller and you can access current_user. You cannot access current_user from console in any other way since it is session based.

Upvotes: 1

Related Questions