vitalyny
unread,May 4, 2010, 4:33:20 PM5/4/10Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to acl9-discuss
Hey,
I implemented authentication with Authlogic and authorization with
Acl9. Now I'm trying to avoid multiple hits to database to check if
user is admin by keeping this in the session.
What I thought is that this code should work:
class ApplicationController < ActionController::Base
...
helper_method :current_user_session, :current_user, :is_admin
...
private
def is_admin
return current_user_session[:is_admin] if defined?
(current_user_session[:is_admin])
current_user_session[:is_admin] = current_user.has_role?
(:admin)
end
So basically on a first call to is_admin helper method, it should add
a boolean value to session[:is_admin] and then for any other calls,
take it from the session. But I receive this error:
undefined method `[]=' for #<UserSession:
{:unauthorized_record=>"<protected>"}>
And I stuck here. What am I doing wrong?