Match in rails routes.rb redirects too many times

I have a route that needs to match something like this
localhost: 3000 / site / admin

and redirect to

local: 3000 / EN / site / admin

here is the route line that should fit this | routes.rb

match '*path', to: redirect("/#{I18n.default_locale}/%{path}")

      

but instead of matching it and redirecting to localhost: 3000 / en / site / admin it redirects infite to this

http://localhost:3000/en/en/en/en/en/en/en/en/en/en/en/en/en/site/admin
(adds /en until browser complains about infite loop)

      

Any idea why this infinite loop is happening? Thanks to

EDIT

Link to my entire routes.rb file

https://gist.github.com/2323762

+1


source to share


1 answer


Do you have a route at the top in the file that catches the "/: locale /: path" url you are redirecting to? If not, your route will fail and catch the "* path" route again (which matches something).



+2


source







All Articles