Is it possible to append a method to the before action callbacks but call it always as the last one before the action is called?
This is probably a bit badly expressed. It’s maybe clearer with an example.
I have the default ApplicationController:
And I have an UsersController with a callback:
@user = User.find(params[:id])
return true if @user == current_user
Now I’ve a small Gem called ActionControl. It makes it possible to authorize a user in a before action callback.
Now the problem is that the authorize callback is at the beginning of the callback queue. But the user is set after the authorization is done. As a consequence I have no access to the @user instance variable in my authorized? method and the authorized? will always be negative.
As workaround for now I add the authorization callback after the specific setter but I think this isn’t really pretty.
I’ve looked into the source code of Rails but haven’t found a way to manipulate the callback queue (or maybe I’ve overlooked something?).
I hope that the question above is a bit more clear :).