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
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
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 Berdt
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/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
Thanks Peter for your suggestion and help… I will look into it
Regards,
srikanth
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs