URL params with a period

suggest change

If you want to support a URL parameter more complex than an id number, you may run into trouble with the parser if the value contains a period. Anything following a period will be assumed to be a format (for example, JSON or XML).

You can work around this limitation with a constraint that broadens the accepted input. /.*/ also matches slashes and an empty segment. Match one path segment instead:

resources :users, constraints: { id: /[^\/]+/ }

For example, this lets the id be an email address.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents