Skip to content

Overriding Load Methods for Declarative Authorization

December 17, 2011

The trick here is to be sure that the methods you are overriding are declared specifically as protected methods.  If they are public or private methods, Declarative Authorization will ignore them.

So, in your UsersController, declare it like so:

def load_user
  @user = User.find_by_login(params[:id])
  raise"Could not find User with login=#{params[:id]}") unless @user

If you do not explicitly raise the error in this method when the record is not found, DA will fall back to it’s default loading methods.


From → Uncategorized

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: