Skip to content

Commit 6fa41fc

Browse files
authored
Merge pull request rails#42483 from chrisbloom7/chrisbloom7/guide-update-action-controller-reserved-methods
Add note to the guides about action names versus ActionController reserved methods
2 parents c2e42a2 + 0c53046 commit 6fa41fc

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

guides/source/action_controller_overview.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,12 @@ The [Layouts and Rendering Guide](layouts_and_rendering.html) explains this in m
6565

6666
Only public methods are callable as actions. It is a best practice to lower the visibility of methods (with `private` or `protected`) which are not intended to be actions, like auxiliary methods or filters.
6767

68+
WARNING: Some method names are reserved by Action Controller. Accidentally redefining them as actions, or even as auxiliary methods, could result in `SystemStackError`. If you limit your controllers to only RESTful [Resource Routing][] actions you should not need to worry about this.
69+
70+
NOTE: If you must use a reserved method as an action name, one workaround is to use a custom route to map the reserved method name to your non-reserved action method.
71+
6872
[`ActionController::Base`]: https://api.rubyonrails.org/classes/ActionController/Base.html
73+
[Resource Routing]: https://guides.rubyonrails.org/routing.html#resource-routing-the-rails-default
6974

7075
Parameters
7176
----------

0 commit comments

Comments
 (0)