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]