From 87c18a5502dd5e7cd37677d7f176a29404942931 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..c6b80f6 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 + after_action :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 + after_action :after_action_filter + prepend_around_action :prepend_around_action_filter +end +---- + == Controllers: Rendering [[rendering]] === Inline Rendering [[inline-rendering]]