Just wondered that I can’t create an action called sort in my
controller… I guess this is due to the fact that there’s already an
“innate” method called “sort” in the controller? Could that be?
Is there a list of “names-not-to-use-for-actions” or something like
that? Or is there a way to use these names anyway?
sort is a ruby method that can be performed, so using it will cause
confusion for the framework:
Did you mean “run the sort method, or sort this object?”.
There are a whole heap of these reversed words (some are even hidden).
I did see a list somewhere, but cannot find it.
To get around the problem rename the action and create a route to it:
map.connect ‘/ControllerName/search’, :controller => ‘ControllerName’,
:action =>‘MyNewName’
Just wondered that I can’t create an action called sort in my
controller… I guess this is due to the fact that there’s already an
“innate” method called “sort” in the controller? Could that be?
Not that I can see in 1.1.6 at least. Perhaps your #sort is not
public? What error are you getting?
Is there a list of “names-not-to-use-for-actions” or something like
that? Or is there a way to use these names anyway?
A good rule of thumb is to not use method names that already exist.
To find them, try this in script/console:
puts ApplicationController.instance_methods.sort
You should probably avoid clobbering private methods too: