Rescue nil in Albums
This commit is contained in:
parent
1a4c689ee6
commit
f509e74938
|
@ -21,7 +21,7 @@ class Admin::SitesController < OrbitBackendController
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
params[:site][:defalut_locale] = "zh_tw" if params[:site][:default_locale].blank?
|
params[:site][:defalut_locale] = nil if params[:site][:default_locale].blank?
|
||||||
@site.update_attributes(params[:site])
|
@site.update_attributes(params[:site])
|
||||||
redirect_to :back
|
redirect_to :back
|
||||||
end
|
end
|
||||||
|
|
|
@ -162,8 +162,9 @@ class ApplicationController < ActionController::Base
|
||||||
#check enable langauge detection
|
#check enable langauge detection
|
||||||
browser_locale = request.env['HTTP_ACCEPT_LANGUAGE'].scan(/^[a-z]{2}/).first rescue nil
|
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)
|
||||||
elsif (@site.default_locale.nil? && @site.enable_language_detection.eql?(false))
|
elsif (@site.default_locale.nil? && @site.enable_language_detection.eql?(false) && session[:locale].nil?)
|
||||||
condition = @site.valid_locales.first
|
session[:locale] = @site.valid_locales.first
|
||||||
|
condition = @site.in_use_locales.include?(session[:locale])
|
||||||
end
|
end
|
||||||
|
|
||||||
session[:locale] = condition ? (browser_locale || session[:locale] || default_locale || backup_locale) : I18n.default_locale.to_s
|
session[:locale] = condition ? (browser_locale || session[:locale] || default_locale || backup_locale) : I18n.default_locale.to_s
|
||||||
|
|
|
@ -215,7 +215,7 @@ class Panel::Gallery::BackEnd::AlbumsController < OrbitBackendController
|
||||||
# tagsToAdd will contain all tag ids which ve to be added in tall album_images
|
# tagsToAdd will contain all tag ids which ve to be added in tall album_images
|
||||||
@images = AlbumImage.all
|
@images = AlbumImage.all
|
||||||
@images.each do |image|
|
@images.each do |image|
|
||||||
image.tagged_ids.concat(tagsToAdd)
|
image.tagged_ids.concat(tagsToAdd) if !tagsToAdd.blank?
|
||||||
tagsToDestroy.each do |tag|
|
tagsToDestroy.each do |tag|
|
||||||
if image.tagged_ids.include?tag
|
if image.tagged_ids.include?tag
|
||||||
image.tagged_ids.delete(tag)
|
image.tagged_ids.delete(tag)
|
||||||
|
|
Loading…
Reference in New Issue