views:

137

answers:

2

Hey, I want to use Devise and acts_as_audited together but when I try and link them using -

class ApplicationController < ActionController::Base
 audit Candidate
 protected

 def current_user
   @user = User.find(user_session)    
 end

I get this error.

stack level too deep

Do I need to do it differently ?

Thanks

A: 

Just to close this off.

stack level too deep is caused because devise has built in auditing on the current_user variable.

So every time you access the variable it causes an infinite loop.

Alex
A: 

Same thing happens with Authlogic alone. Solution is to add the :except argument with the following fields(see below). Perhaps something similar will work with Devise as well.

# Define explicitly otherwise "Stack Level Too Deep"

acts_as_audited :except => [ :persistence_token,
:perishable_token, :login_count,
:failed_login_count,
:last_request_at, :current_login_at, :last_login_at, :current_login_ip,
:last_login_ip ]

bseanvt