Skip to content
This repository has been archived by the owner on Dec 12, 2021. It is now read-only.

is it always need Authentication.rb in lib when combined with authlogic #21

Closed
bopbi opened this issue Dec 23, 2009 · 4 comments
Closed

Comments

@bopbi
Copy link

bopbi commented Dec 23, 2009

why always shows

undefined local variable or method `current_user'

when i am defined ability and using authlogic

@molte
Copy link

molte commented Dec 23, 2009

You need to define the following methods in your ApplicationController:

def current_user_session
  return @current_user_session if defined?(@current_user_session)
  @current_user_session = UserSession.find
end

def current_user
  return @current_user if defined?(@current_user)
  @current_user = current_user_session && current_user_session.user
end

@bopbi
Copy link
Author

bopbi commented Dec 23, 2009

ok. thanks

it should be documented in the cancan README

@molte
Copy link

molte commented Dec 24, 2009

The README already states that a current_user method is required, but CanCan works with any authentication system and the method might therefore look different.

Actually, as far as I remember the methods is documented in the authlogic README.

@ryanb
Copy link
Owner

ryanb commented Dec 31, 2009

Right, as molte stated, the current_user method is mentioned in the README and should be defined. How one defines this is up to them and dependent on their authentication solution.

This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants