Is it possible to append a method to the before action callbacks but
it always as the last one before the action is called?
This is probably a bit badly expressed. It’s maybe clearer with an
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
https://github.com/tobiasfeistmantl/action_control. It makes it
to authorize a user in a before action callback.
Now the problem is that the authorize callback is at the beginning of
callback queue. But the user is set after the authorization is done. As
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
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 :).