Hi all 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? Thanks, Josh -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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'' Are there better ways? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 12/12/06, Joshua Muheim <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Hi all > > 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: puts ApplicationController.private_instance_methods.sort ...although private methods in Object and Kernel are probably safe to override if you must: a, k, o = [ApplicationController, Kernel, Object].map{|m| m.private_instance_methods} puts (a - k - o).sort --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thank you guys. It''s kind of a pitty that Rails does not use some sort of naming convention for actions, I saw frameworks that do, e.g. def action_index end def action_sort end etc. Names like "sort" are precious for a good looking and indexed website, and to create a route for every little action is kind of making tired... -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---