Christos Zisopoulos
2006-Oct-26 01:53 UTC
routes.rb priorities and REST resources; Bug or documentation vagueness?
I came across this little annoyance(?!) while upgrading a project from 1.1.6 to Edge Rails. I was trying to add a resource mapping for my Post model. I did as instructed and added... map.resources :posts ...to config/routes.rb. What I didn''t pay much attention to was that I added the command to the very end of the file (before the ''end'' keyword of course; I am not that thick!). Anyway, everything seemed to work fine until I tried a CRUD operation other than the ''/posts'' index action. I started getting strange ''Unknown Action 2'' messages. Well, it took me a couple hours to figure it out; any mapped resources must be added *before* these two lines in routes.rb: # Install the default route as the lowest priority. map.connect '':controller/:action/:id.:format'' map.connect '':controller/:action/:id'' I haven''t had a chance to investigate if this is a routing bug (the code looks a tad scary!). Or maybe it is just a vague point in the documentation (i.e. routes.rb comments) I fear this little detail might get in the way of a lot of people who are eager to jump into REST, and might not spend enough time to read the comments, even if they are in front of them. Before REST it might not have been an issue as simple apps never touched routes.rb. Now though... -christos --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Rick Olson
2006-Oct-26 02:31 UTC
Re: routes.rb priorities and REST resources; Bug or documentation vagueness?
> I haven''t had a chance to investigate if this is a routing bug (the > code looks a tad scary!). Or maybe it is just a vague point in the > documentation (i.e. routes.rb comments) > > I fear this little detail might get in the way of a lot of people who > are eager to jump into REST, and might not spend enough time to read > the comments, even if they are in front of them. > > Before REST it might not have been an issue as simple apps never > touched routes.rb. Now though...Routes go from top to bottom. This has always been a key point with routes. I find myself actually removing the default open connect route and only going with explicitly set routes/resources. -- Rick Olson http://weblog.techno-weenie.net http://mephistoblog.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 -~----------~----~----~----~------~----~------~--~---
Luca Mearelli
2006-Oct-26 11:33 UTC
Re: routes.rb priorities and REST resources; Bug or documentation vagueness?
hi, 2006/10/26, Rick Olson <technoweenie-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:> I find myself actually removing the default open connect route and > only going with explicitly set routes/resources.and this is much more important if you want to somehow limit your app to what is offered as a restful resource since if you don''t remove the default routes then the canonical actions will be available! bye Luca Mearelli -- http://spazidigitali.com - http://thetyper.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 -~----------~----~----~----~------~----~------~--~---