RESTful routes are making me a sad panda. I''m using rails 1.2.1 and have an event controller with create, update, show, etc. I also have my resources mapped in routes.rb: map.resources :events I thought that the RESTful url for updating an event should be: /events/1.xml But I keep getting a 404 for that. On the other hand, if I post to: /events/update/1.xml it works just fine. Note that I still have the default routes at the bottom of my routes.rb: # Install the default route as the lowest priority. map.connect '':controller/:action/:id.:format'' map.connect '':controller/:action/:id'' But if I take that out then neither the /events/id nor the /events/update/id versions work. We''re not supposed to use the /controller/action type urls with REST right? Does anyone know why map.resources isn''t working correctly or what I can do to debug it? thanks, Ben --~--~---------~--~----~------------~-------~--~----~ 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 2/13/07, Ben Munat <bmunat-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > RESTful routes are making me a sad panda. > > I''m using rails 1.2.1 and have an event controller with create, update, > show, etc. I also have my resources mapped in routes.rb: > > map.resources :events > > I thought that the RESTful url for updating an event should be: > > /events/1.xml > > But I keep getting a 404 for that. On the other hand, if I post to: > > /events/update/1.xml > > it works just fine. > > Note that I still have the default routes at the bottom of my routes.rb: > > # Install the default route as the lowest priority. > map.connect '':controller/:action/:id.:format'' > map.connect '':controller/:action/:id'' > > But if I take that out then neither the /events/id nor the > /events/update/id versions work. > > We''re not supposed to use the /controller/action type urls with REST > right? Does anyone know why map.resources isn''t working correctly or > what I can do to debug it? > > thanks, > > BenBen, The update route generated by map.resources will be events/:id (ex: events/1) using HTTP PUT, not /events/1.xml. I recently put together an example app to help people learn REST. You can use it as an example if it helps... Code: http://svn.depixelate.com/applications/restful_product_tracker Blog post: http://depixelate.com/2007/1/19/restful-product-tracker -- Zack Chandler http://depixelate.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 -~----------~----~----~----~------~----~------~--~---
Zack Chandler wrote:> On 2/13/07, Ben Munat <bmunat-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> RESTful routes are making me a sad panda. > > Ben, > > The update route generated by map.resources will be events/:id (ex: > events/1) using HTTP PUT, not /events/1.xml. > > I recently put together an example app to help people learn REST. You > can use it as an example if it helps... > > Code: http://svn.depixelate.com/applications/restful_product_tracker > Blog post: http://depixelate.com/2007/1/19/restful-product-tracker >Hey Zack, yeah it turned out that I was using the wrong curl option... it''s -T to do a PUT... I was still using -d, which was doing a POST. With the -T, it works like a champ... well, after I commented out the verify method stuff that the generator put in there anyway. I wasn''t completely lost, however... I saw that it was doing a post and had tried to figure out how to add the _method=PUT param. Forgot to mention that... And actually, I thought doing the .xml encouraged rails to intervene and considered the POST a PUT. Sigh. So much to learn. Thanks for the links... will definitely check them out. b --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
this bash script might help: http://snippets.dzone.com/posts/show/3521 i wrote it to help me test my REST apps - might prove useful. ed On 2/13/07, Ben Munat <bmunat-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > Zack Chandler wrote: > > On 2/13/07, Ben Munat <bmunat-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> RESTful routes are making me a sad panda. > > > > Ben, > > > > The update route generated by map.resources will be events/:id (ex: > > events/1) using HTTP PUT, not /events/1.xml. > > > > I recently put together an example app to help people learn REST. You > > can use it as an example if it helps... > > > > Code: http://svn.depixelate.com/applications/restful_product_tracker > > Blog post: http://depixelate.com/2007/1/19/restful-product-tracker > > > > Hey Zack, yeah it turned out that I was using the wrong curl option... > it''s -T to do a PUT... I was still using -d, which was doing a POST. > With the -T, it works like a champ... well, after I commented out the > verify method stuff that the generator put in there anyway. > > I wasn''t completely lost, however... I saw that it was doing a post and > had tried to figure out how to add the _method=PUT param. Forgot to > mention that... And actually, I thought doing the .xml encouraged rails > to intervene and considered the POST a PUT. Sigh. So much to learn. > > Thanks for the links... will definitely check them out. > > b > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---