I am new to ruby, i would like to pass parameters in the url and receive it in controller.
I am expecting operation like
www.mysite.com/getuser/id/22
where getuser is the param name and 22 is its value.
Please provide me if there is any useful links that i can refer to.
Thanks in advance
Please read everything in the Rails Guide to Routing. There are two main cases there:
RESTful routes: only use GET, PUT, POST, DELETE. Rails maps that by using the method
resources.resources :pageswill lead to the following routes (and URLs) automatically:Other routes: There is a rich set of methods you can use in your routes file to add additional routes. But keep in mind: If you just want to address a resource, it is better to stick to restful routes. A typical example is_
match ':controller(/:action(/:id))'. This allows URLs like:localhost:3000/sites/help: controller ==SitesController, action ==helplocalhost:3000/sites/search/something: controller ==SitesController, action ==search, parameter inparamsissomethingunder the keyid. So inside the actionsearch, you will findparams[:id]bound to"something".