I have a problem when I try to change the locale on my webapp. In dev mode (webrick) all is ok, but when I deploy on my prd env (Unicorn + NGINX) a strange behaviour happens:
For each flag i set this link
<%= link_to "<button class='btn flag flag-#{lang}'></button>".html_safe, {controller: 'amministratore/localecontroller', action: 'set', locale: lang} %>
where lang
is the locale.
Inside the controller I have this simple logic:
def set
I18n.locale = params[:locale] || I18n.default_locale
redirect_to amministratore_items_url
end
The problem is this: When I click on the flags (on dev all is ok), the page is not reloaded but the locale is changed (checked with <%=debug(params)%>
. This mean that the other urls inside the page (with default_url_option that set the current locale to all urls) have not the correct locale.
Example
- Current state : (url in page) https://stackoverflow.com/questions/ask?locale=it - I18n.locale = "it"
- Click on flag EN
- Updated state : (url in page) https://stackoverflow.com/questions/ask?locale=it - I18n.local = "en"
The same requests between prd and dev are equals (headers, etc, etc)
Honestly I do not know where to look the solution...
Thanks