Reputation: 315
I have created some route like this:
get 'foo/:offset' => 'foo#action', :as => :foo, :constraint => { id: /\d+/ }
It works fine, but: I want rails to route /foo
to foo#action
if no parameter specified, so not only urls like /foo/123
will be routed but simple /foo
too.
How can I change constraint for this? Thanks for help!
Upvotes: 0
Views: 105
Reputation: 705
I don't know if this is the best solution, but it's a simple one:
Create a route for /foo
, and another for /foo/:offset
to the same controller and action!
Upvotes: 1