I have a bilingual rails 4 application deployed in Heroku - russian & english. Everything worked until one day the locale switcher broke for no reason. It's working completely fine on development and production version - when I point to language link it shows the normal link with 'localhost:3000/en' or 'localhost:3000/ru' param. But in Heroku it shows 'abarskaya.com/%7B:locale=>' instead of 'abarskaya.com/ru' or 'abarskaya.com/en'. This is really strange as I didn't change anything. Here's my application controller
class ApplicationController < ActionController::Base
protect_from_forgery
before_filter :set_locale
protected
def set_locale
I18n.locale = params[:locale] || session[:locale] || I18n.default_locale
end
# ensure locale persists
def default_url_options(options={})
logger.debug "default_url_options is passed options: #{options.inspect}\n"
{ locale: I18n.locale }
end
end
And my route.rb file is:
scope "(:locale)", locale: /ru|en/ do
get 'about' => 'home#about', :as => 'about'
get 'services' => 'home#services', :as => 'services'
get 'contacts' => 'home#contacts', :as => 'contacts'
end
root :to => 'home#index'
get '/:locale' => 'home#index'
Here's the switcher itself in shared/_header.html.erb partial (I'm using rails_bootstrap_navbar gem)
<li class="dropdown visible-desktop">
<a href="#" class="dropdown-toggle" data-toggle="dropdown"><%= image_tag(:en == locale ? 'us-flag.png' : 'ru-flag.png') %> <b class="caret"></b></a>
<ul class="dropdown-menu">
<li class="nav-header"><%= t(:language) %></li>
<li class="divider"></li>
<%= menu_item 'English', locale: 'en' %>
<%= menu_item 'Русский', locale: 'ru' %>
</ul>
</li>
Any help will be appreciated. Anyway I'm pretty sure that I have some dumb mistake somewhere. ;)