varunl
varunl

Reputation: 20269

Rails routing based on GET params

I want such a routing table:

"/search" => "search#home" # Without GET params, call action "home".
"/search?*" => "search#result" # Call "result" action when search has params.

Is it possible to do that?

Upvotes: 3

Views: 1541

Answers (1)

Dave Newton
Dave Newton

Reputation: 160291

One way would be to use an advanced constraint.

Check for the presence of a query string. I think you'd need to put this ahead of the home route.

(This is all untested/unconfirmed.)

Upvotes: 1

Related Questions