From 5109d04881ba5b23c2b2bb3e157e2e7b20058c9c 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 | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/README.adoc b/README.adoc index 9a71bea..b0ed67a 100644 --- a/README.adoc +++ b/README.adoc @@ -266,6 +266,28 @@ class UsersController < ApplicationController end ---- +=== Action Filters Order [[action-filters-order]] + +Order controller filter declarations in the order in which they will be executed. +For reference, see https://dev.to/timkrins/an-experiment-with-controller-action-callbacks-in-rails-c3p[An experiment with controller action callback order in Rails]. + +[source,ruby] +---- +# bad +class UsersController < ApplicationController + append_after_action :append_after_action_filter + prepend_around_action :prepend_around_action_filter + before_action :before_action_filter +end + +# good +class UsersController < ApplicationController + before_action :before_action_filter + append_after_action :append_after_action_filter + prepend_around_action :prepend_around_action_filter +end +---- + == Controllers: Rendering [[rendering]] === Inline Rendering [[inline-rendering]]