If you’re getting NameError (uninitialized constant UnknownAction) using UnknownAction in the ‘rescue_action_in_public’ method, try
to use the full reference (::ActionController::UnknownAction) instead of ActionController::UnknownAction.
classApplicationController<ActionController::Baseattr_accessor:auth_err#--------------------------------------------# rescue_action_in_public()defrescue_action_in_public(exception)caseexceptionwhenActiveRecord::RecordNotFoundunauthorised_actionRecordNotFoundErrorwhen::ActionController::UnknownActionunauthorised_actionPageNotFoundErrorelselog_error(exception)redirect_to('/500.html')endend#--------------------------------------------# unauthorised_action()defunauthorised_action(details=nil)# If one unauthorised_action has already occurred, don't need to log the restreturnfalseifself.auth_err# Log the unauthorised_actionuser="Unknown user"user="User '"+@session[:user].login+"'"if@session[:user]msg=user+" denied access to '"+controller_name+"/"+action_name+"'"msg+=" ("+details+")"ifdetailslogger.error(msg)self.auth_err=trueredirect_to('/404.html')andreturnfalserescueself.auth_err=truereturnfalseendend