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

CategoriesRuby on Rails

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 => /[^\/]+/ }

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.