To use a custom redirection when a resource is not authorized we only need to add an user_not_authorized
method to the controller, and define the redirection.
Example:
class Groups::MembershipRequestsController < ApplicationController
def new
@membership_request = MembershipRequest.new
@group = find_group
authorize @membership_request
end
# (...)
private
def user_not_authorized
redirect_to new_user_registration_path
end
end