diff --git a/app/controllers/admin/sites_controller.rb b/app/controllers/admin/sites_controller.rb index 13d64421..1883533b 100644 --- a/app/controllers/admin/sites_controller.rb +++ b/app/controllers/admin/sites_controller.rb @@ -21,20 +21,27 @@ class Admin::SitesController < OrbitBackendController end def update - - if params[:site][:default_locale] && @site.enable_language_detection.eql?(true) - Site.update_all({:enable_language_detection => false}) - elsif params[:site][:enable_language_detection] && @site.default_locale.present? - Site.update_all({:default_locale => nil}) - end - if params[:site][:default_bar_color] params[:site][:mobile_bar_color] = [] end # if params[:site][:enable_language_detection] # Site.update_all({:default_locale => nil}) # end + + if params[:site][:phone_number].nil? + params[:site][:phone_number] = [] + else + params[:site][:phone_number] = params[:site][:phone_number].values + end + @site.update_attributes(params[:site]) + + if params[:site][:enable_language_detection].eql?("0") + Site.update_all({:enable_language_detection => false}) + elsif params[:site][:enable_language_detection].eql?("1") + Site.update_all({:default_locale => nil}) + end + redirect_to :back end diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 631b3e12..c8fcfe2f 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -163,6 +163,7 @@ class ApplicationController < ActionController::Base browser_locale = request.env['HTTP_ACCEPT_LANGUAGE'].scan(/^[a-z]{2}/).first rescue nil if browser_locale.eql?("zh") condition = @site.in_use_locales.include?("zh_tw") + browser_locale = "zh_tw" else condition = @site.in_use_locales.include?(browser_locale) end diff --git a/app/models/site.rb b/app/models/site.rb index a1b043c4..a37cbbb3 100644 --- a/app/models/site.rb +++ b/app/models/site.rb @@ -44,7 +44,7 @@ class Site field :terms_of_use, localize: true field :google_analytics field :address - field :phone_number, :type => Hash,:default=>{} + field :phone_number, :type => Array,:default=>[] field :mobile_bar_color, :type => Array, :default=>[] diff --git a/app/views/admin/sites/preference.html.erb b/app/views/admin/sites/preference.html.erb index 6d96049a..a657e417 100644 --- a/app/views/admin/sites/preference.html.erb +++ b/app/views/admin/sites/preference.html.erb @@ -239,7 +239,7 @@ -