Reputation: 17803
I have a route like this:
match '/pages/:name/preview' => 'pages#page_preview'
But, it is giving me an error 'No route matches', when a route like this comes /pages/a.com/preview
. I tried URL encoding the . character to %2E
, but then also, the same error comes. I have also setup resources on the pages (resources :pages
) before defining the preview route.
The route is working fine for all other routes, which do not have .
character in the name parameter (space and ? etc are working fine)
Upvotes: 1
Views: 181
Reputation: 23344
This is because the dot is used as a separator for formatted routes. To get out of this, add a constraint which overrides this.
match '/pages/:name/preview' => 'pages#page_preview', :constraints => { :name => /[^\/]+/ }
This will allows anything except a slash.
Upvotes: 4