When I input some text in the text_field and click `Search`, the `find`
function can print out the value of that text.
This looks magic to me. Because in the `route`, the variable name is
`id`, but in the `controller`, this variable can be used by `params`. I
was wondering whether `id` is a magic variable that maps to `param`.
When I input some text in the text_field and click `Search`, the `find`
function can print out the value of that text.
This looks magic to me. Because in the `route`, the variable name is
`id`, but in the `controller`, this variable can be used by `params`. I
was wondering whether `id` is a magic variable that maps to `param`.
Does anyone have ideas about this. Thanks!
In the controller, every parameter that was gleaned from the routing process is available in the params hash. This includes anything that was named in the route that matched the request, and POST or querystring (GET) variables. The only parts of the request that are not in that hash are the session and cookie parameters.
This gives you a one-stop-shop for any parameter you need, without having to specify in great detail precisely where you might have expected to find that parameter.