Routing through query string in rails 3?

I wonder if you can redirect the request to a specific controller with a query string.

eg. if the request contains the q-hello request, it will be sent to the specific controller.

and if it contains "search = hello", it will be sent to another controller.

Is it possible?

thank!

+3
source share
2 answers

Such a strange way to do something, but here is something that can help.

Suppose you have a route like this:

map.connect ':controller/:action/:id'

Then / people / edit / 1? gender = male will go to the editing action on the people controller, and params [: id] will be 1, and params [: gender] will be "male".

, , , , . , , RESTful, , , , .

, q . /people/q/hello /people/search/hello.

:

map.connect ':controller/:action'

/people/index? q = hello /people/index? search = hello if params [].

: ( ), .

+1
0

Source: https://habr.com/ru/post/1755868/


All Articles