Skip to content

Commit 5109d04

Browse files
committed
Add Action Filters Order section
1 parent 2e7d125 commit 5109d04

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

Diff for: README.adoc

+22
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,28 @@ class UsersController < ApplicationController
266266
end
267267
----
268268

269+
=== Action Filters Order [[action-filters-order]]
270+
271+
Order controller filter declarations in the order in which they will be executed.
272+
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].
273+
274+
[source,ruby]
275+
----
276+
# bad
277+
class UsersController < ApplicationController
278+
append_after_action :append_after_action_filter
279+
prepend_around_action :prepend_around_action_filter
280+
before_action :before_action_filter
281+
end
282+
283+
# good
284+
class UsersController < ApplicationController
285+
before_action :before_action_filter
286+
append_after_action :append_after_action_filter
287+
prepend_around_action :prepend_around_action_filter
288+
end
289+
----
290+
269291
== Controllers: Rendering [[rendering]]
270292

271293
=== Inline Rendering [[inline-rendering]]

0 commit comments

Comments
 (0)