Pretty much what I have mentioned in the title. I am using CanCan::Ability in my code to check permissions and abilities. It expects a current_user method to be defined. I am guessing it comes from devise (but not sure), and I wish to override it. Whats the best way to do that?
Asked
Active
Viewed 2,192 times
2 Answers
1
It's found here in the source code. It's nothing to do with devise, though. The documentation is found above the method and describes overwriting it.

Lee Jarvis
- 16,031
- 4
- 38
- 40
1
current_user
is implemented by devise in this eval'ed block (which, I believe is called indirectly by the devise_for(:user)
in your config/routes.rb
). If you want to override it, you should be able to define your own current_user
method in your ApplicationController
.

cbeer
- 1,221
- 10
- 13
-
So if I override current_user in my ApplicationController, will the same current_user will be passed in devise_for? I want that devise's current_user is passed in the devise_for function and my overridden current_user is used in my application code. – Rajat Sep 17 '12 at 18:15