From 8cd0c0774ac6a99fcc692bdee3e0cd5fa827ae9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B1=E5=8D=9A=E4=BA=9E?= Date: Sat, 27 Nov 2021 16:50:46 +0800 Subject: [PATCH] fix error --- app/controllers/galleries_controller.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/galleries_controller.rb b/app/controllers/galleries_controller.rb index 12b272d..71a276f 100644 --- a/app/controllers/galleries_controller.rb +++ b/app/controllers/galleries_controller.rb @@ -64,7 +64,7 @@ class GalleriesController < ApplicationController galleries = albums.collect do |a| doc = Nokogiri::HTML(a.description.to_s) alt_text = doc.text.empty? ? 'gallery image' : doc.text - colors = album_color_map[a.id] + colors = album_color_map[a.id] || [] { "album-name" => a.name, "album-description" => a.description, @@ -86,7 +86,7 @@ class GalleriesController < ApplicationController params = OrbitHelper.params album = Album.find_by_param(params[:uid]) flag = show_desc? - colors = AlbumColor.where(:album_id=> album.id).pluck(:color,:album_card_background_color,:album_card_text_color)[0] rescue [] + colors = (AlbumColor.where(:album_id=> album.id).pluck(:color,:album_card_background_color,:album_card_text_color)[0])||[] rescue [] images = album.album_images.asc(:order).collect do |a| alt_text = (a.description.blank? ? "gallery image" : Nokogiri::HTML(a.description.to_s).text()) { @@ -150,7 +150,7 @@ class GalleriesController < ApplicationController galleries = albums.collect.with_index do |a,i| doc = Nokogiri::HTML(a.description.to_s) alt_text = doc.text.empty? ? 'gallery image' : doc.text.strip - colors = album_color_map[a.id] + colors = album_color_map[a.id] || [] thumb_src = a.cover_path || "/assets/gallery/default.jpg" cover_image = AlbumImage.find(a.cover) rescue a.album_images.first image_description = a.description @@ -193,7 +193,7 @@ class GalleriesController < ApplicationController counts = OrbitHelper.widget_data_count images = AlbumImage.where({album_id:{"$in"=>album_ids}}).desc(:id).limit(counts *5).sample(counts) images = images.each_with_index.collect do |a,i| - colors = album_color_map[a.album_id] + colors = album_color_map[a.album_id] || [] alt_text = (a.description.blank? ? "gallery image" : Nokogiri::HTML(a.description).text().strip) f = a.file ab = albums_map[a.album_id]