I have following routes: map.resources :users ruby script/console>> rs = ActionController::Routing::Routes >> rs.recognize_path(''/users/2'')=> {:controller=>"users", :action=>"2"} The output is not correct. However if I user helper, I get correct answer.>> helper.users_path=> "/users" How do I play with REST routes in console? -- 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 -~----------~----~----~----~------~----~------~--~---
You can look on a cheatsheet to see what to expect: http://www.scribd.com/doc/126939/RESTcheatsheet On Tue, May 20, 2008 at 7:30 AM, Raj Singh <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > I have following routes: > map.resources :users > > > ruby script/console > >> rs = ActionController::Routing::Routes > >> rs.recognize_path(''/users/2'') > => {:controller=>"users", :action=>"2"} > > > The output is not correct. > > However if I user helper, I get correct answer. > >> helper.users_path > => "/users" > > How do I play with REST routes in console? > -- > Posted via http://www.ruby-forum.com/. > > > >-- Appreciated my help? Reccommend me on Working With Rails http://workingwithrails.com/person/11030-ryan-bigg --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
You don''t really need console to see the routes. You can create a new empty project and change the routes.rb without adding anything else (no appropriate controllers, models, views, no anything) and Rake routes will still list the routes that your routes.rb would create. It is a fast way to check your routing. Good luck --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I know rake routes prints all the routes. However I wanted to know why the routing was not working with rs. However I found the answer. Instead of>> rs.recognize_path(''/users/2'')I need to use>> rs.recognize_path(''/users/2'',:method => :get)for a resource. -- 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 -~----------~----~----~----~------~----~------~--~---