Cyrus
Cyrus

Reputation: 3717

current_user returns nil even when user_signed_in? returns true

I have devise 2.1.2 and cancan 1.6.8 installed.

The current_user helper from devise works fine in my controllers, but is not working the view templates. I'm confused why this is happening. I've been able to use current_user in my view files before.

I tried adding the before_filter authenticate_user! and that didn't help.

Worse comes to worse, I'll add a before filter to the application_controller that says @current_user = current_user but that seems silly.

It's weird that current_user returns nil while user_signed_in? returns true.

Any thoughts on how to get this resolved?

Upvotes: 2

Views: 969

Answers (1)

Cyrus
Cyrus

Reputation: 3717

In the meantime,warden.authenticate(:scope => :user) seems to return the current_user so I'm just going to add that to my application helper.

Upvotes: 4

Related Questions