I’m puzzling on the following problem: in my web app users can select their language from a dropdown box. Upon selection, a piece of Javascript takes the current url, replaces the old locale substring in it with the new locale string and sets the window.location to the new url. That works great as long as the URL the result of a GET request.
My problem occurs when the user posts a form and it returns a validation error. The url is now a POST url, that (in my case) does not work with a GET request. Hence, if the user now decides to switch language, an invalid GET request will be sent to the server.
Any ideas how to solve this?
To be a little more specific: I’m running into this problem in Rails 3.0.9 on the registration form of Devise (1.4.2)
I often write my own routes to avoid the exact problem you are describing. I think it’s a big flaw in Rails routing.
You may be able to change the Devise routes, and the rest of your resource routes, so that your GET and POST URLs look identical. Here’s an example of what I mean.
It’s a bit more work doing things that way, though.
You could always disable the locale select for the pages where you have problems.