diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 68f49e3b..494b497e 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -128,8 +128,8 @@ class ApplicationController < ActionController::Base # set site if exist or create site @site = Site.first || Site.create({:valid_locales => [], :in_use_locales => []}) session[:site] = @site.id - @site_in_use_locales = @site.in_use_locales - @site_valid_locales = @site.valid_locales + @site_in_use_locales = site_locales_default_head(@site.in_use_locales) + @site_valid_locales = site_locales_default_head(@site.valid_locales) end def set_current_item @@ -164,4 +164,14 @@ class ApplicationController < ActionController::Base end end + def site_locales_default_head(locales) + if locales[0].eql? I18n.locale.to_s + locales + else + a = Array.new(locales) + shift_out = a.delete(I18n.locale.to_s) + [shift_out] + a + end + end + end diff --git a/app/helpers/admin/ad_images_helper.rb b/app/helpers/admin/ad_images_helper.rb index 1f2422fc..b09bd263 100644 --- a/app/helpers/admin/ad_images_helper.rb +++ b/app/helpers/admin/ad_images_helper.rb @@ -1,7 +1,3 @@ module Admin::AdImagesHelper - def active_when_default_locale_eq locale - locale.to_sym == I18n.default_locale ? 'active': '' - end - end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index c36a420f..c59f16c3 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -2,12 +2,6 @@ module ApplicationHelper FLASH_NOTICE_KEYS = [:error, :notice, :warning] - def site_valid_locales_default_head - index = @site_valid_locales.rindex I18n.default_locale.to_s - shift_out = @site_valid_locales.shift(index) - @site_valid_locales += shift_out - end - def colorize_in_use_locale(locale) @site_in_use_locales.include?(locale)? 'green' : 'red' end @@ -147,4 +141,8 @@ module ApplicationHelper javascripts end + def active_when_current_locale_eq(locale) + locale.to_sym == I18n.locale ? 'active': '' + end + end diff --git a/app/views/admin/ad_images/_form.html.erb b/app/views/admin/ad_images/_form.html.erb index cd04b4fe..be5f2b47 100644 --- a/app/views/admin/ad_images/_form.html.erb +++ b/app/views/admin/ad_images/_form.html.erb @@ -130,14 +130,14 @@