0
votes

There is no user and roles table. I have a tabless model for users and roles. user information is set in the application controller with the values from the environmental variables, for this one I have hard coded the value. The role information comes from the service.

#Application controller setting the user object
before_filter :set_user

def set_user
 @user = User.new(:id => 123)
end

I am using cancan for authorization and ability.rb doesnt see this @user or user and comes in as nil.Does ability load before the application controller? Am I missing anything in the controllers for cancan? I have load_and_authorize_resource in the controllers.

Any suggestion will be greatly helpful.

Thanks Ramya

1

1 Answers

1
votes

Add this method in your ApplicationController if you don't have it:

def current_user
  @user
end