Skip to main content

Ruby on Rails: allow parameters to have “.” (dot)

By default, dot in rails router is used to separate the format from the rest of the url. To allow dot in a parameter, override the constraint. The below example allows any character except slash:

get "/:user/contributions" => 'users#contributions', :constraints => { :user => /[^\/]+/ }
https://cityad-all-prod.s3.amazonaws.com/public/2023-12/200x200%20rails-2_4_0.jpg
Please login to post comments: _TODO