Fix a bug when setting the site

Fix devise login
This commit is contained in:
chris committed 2013-04-29 20:17:44 +08:00
1 parent e028791d68
commit 67bb08c338
4 files changed
+18 -5

No files matched your search

+3 -3
View File
@@ -13,7 +13,7 @@ class ApplicationController < ActionController::Base
layout :layout_by_resource
helper :admin, :orbit_form
before_filter :set_locale, :set_site, :prepare_for_mobile
before_filter :set_site, :set_locale, :prepare_for_mobile
helper_attr :site_valid_locales
@@ -135,10 +135,10 @@ class ApplicationController < ActionController::Base
if LIST[:forbidden_item_names].include?(env['PATH_INFO'].split('/')[1].to_s)
condition = VALID_LOCALES.include?(session[:locale])
elsif session[:locale]
condition = @site_in_use_locales.include?(session[:locale])
condition = @site.in_use_locales.include?(session[:locale])
else
browser_locale = request.env['HTTP_ACCEPT_LANGUAGE'].scan(/^[a-z]{2}/).first rescue nil
condition = @site_in_use_locales.include?(browser_locale)
condition = @site.in_use_locales.include?(browser_locale)
end
session[:locale] = condition ? (browser_locale || session[:locale]) : I18n.default_locale.to_s
I18n.locale = session[:locale].to_sym