match '*path', to: redirect("/#{I18n.default_locale}/%{path}")
to be something along the lines of
ruby
match '*path', to: redirect({|params, request| "/#{I18n.default_locale}#{request.fullpath}"})
If you want to maintain the request format sent in /posts.json, also it should be noted that a 302 redirect will not resubmit post data, possibly a 307. This method of redirection you need to pay close attention that any urls placed in ajax calls have the locale otherwise there may be some unforeseen bugs, especially with POST requests
you may want to update
to be something along the lines of
If you want to maintain the request format sent in /posts.json, also it should be noted that a 302 redirect will not resubmit post data, possibly a 307. This method of redirection you need to pay close attention that any urls placed in ajax calls have the locale otherwise there may be some unforeseen bugs, especially with POST requests