From 8a53e04515053646f232536a378a5776d262b995 Mon Sep 17 00:00:00 2001 From: Yauheni Dakuka Date: Mon, 11 Dec 2023 21:57:12 +0400 Subject: [PATCH] Add Action Filters Order section --- README.adoc | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/README.adoc b/README.adoc index 9a71bea..3262bd5 100644 --- a/README.adoc +++ b/README.adoc @@ -266,6 +266,43 @@ class UsersController < ApplicationController end ---- +=== Action Filters Order [[action-filters-order]] + +Order controller filter declarations in the order in which they will be executed. + +[source,ruby] +---- +# bad +class UsersController < ApplicationController + after_action :after_action_filter + around_action :around_action_filter1 + before_action :before_action_filter1 + prepend_around_action :prepend_around_action_filter + prepend_after_action :prepend_after_action_filter + append_around_action :append_around_action_filter + append_before_action :append_before_action_filter + around_action :around_action_filter2 + prepend_before_action :prepend_before_action_filter + append_after_action :append_after_action_filter + before_action :before_action_filter2 +end + +# good +class UsersController < ApplicationController + before_action :before_action_filter1 + before_action :before_action_filter2 + around_action :around_action_filter1 + around_action :around_action_filter2 + after_action :after_action_filter + append_before_action :append_before_action_filter + append_around_action :append_around_action_filter + append_after_action :append_after_action_filter + prepend_before_action :prepend_before_action_filter + prepend_around_action :prepend_around_action_filter + prepend_after_action :prepend_after_action_filter +end +---- + == Controllers: Rendering [[rendering]] === Inline Rendering [[inline-rendering]]