Hi, I am new to ruby on rails and i have urls which are in the form of http://demo.com/demo/home?demo=10 i want to reformat the above url to user friendly way like http://demo.com/demo/home/10 Is there any way how to do it. Thanks Srikanth -- 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 -~----------~----~----~----~------~----~------~--~---
On 16 Mar 2008, at 09:14, Srikanth Gop wrote:> I am new to ruby on rails and i have urls which are in the form of > > http://demo.com/demo/home?demo=10 > i want to reformat the above url to user friendly way like > http://demo.com/demo/home/10Looks like named routes to me (code in routes.rb): map.demo "/demo/home/:demo", :controller => "demo", :action => "home" You can then just use "demo_path(:demo => 10)" in your controllers/ views to get the url you want. Though I think you''d be better off rethinking your whole app structure into something more RESTful. Getting a book on Rails (e.g. The Rails Way) could be a good idea. Best regards Peter De Berdt --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Peter De Berdt wrote:> On 16 Mar 2008, at 09:14, Srikanth Gop wrote: > >> I am new to ruby on rails and i have urls which are in the form of >> >> http://demo.com/demo/home?demo=10 >> i want to reformat the above url to user friendly way like >> http://demo.com/demo/home/10 > > Looks like named routes to me (code in routes.rb): > > map.demo "/demo/home/:demo", :controller => "demo", :action => "home" > > You can then just use "demo_path(:demo => 10)" in your controllers/ > views to get the url you want. > > Though I think you''d be better off rethinking your whole app structure > into something more RESTful. Getting a book on Rails (e.g. The Rails > Way) could be a good idea. > > > Best regards > > Peter De BerdtThanks Peter for your suggestion and help.. I will look into it Regards, srikanth -- 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 -~----------~----~----~----~------~----~------~--~---