Reputation: 7166
I have a route to which I am adding a constraint for an integer to be anywhere between 0-2 i.e. the integer can either be 0,1 or 2. I tried something, but that's not helping.
Route:
get 'books/:book_type', to: 'books#type', constraints: { book_type: /\d{0,2}/ }
Is this right or am I missing something here?
Upvotes: 0
Views: 80
Reputation: 19049
{0,2}
is not a digit between 0 and 2, but 0 to 2 of preceding tokens. (in your case, it is\d
- a digit from 0 to 9). You must have meant [0-2]
.
Upvotes: 1