fix error

This commit is contained in:
邱博亞 2021-03-30 15:45:22 +08:00
parent c40c552a1d
commit c1a5e89d57
2 changed files with 5 additions and 6 deletions

View File

@ -381,8 +381,8 @@ class Admin::GalleriesController < OrbitAdminController
if sheet.count <= 203 if sheet.count <= 203
sheet.each_with_index do |row, i| sheet.each_with_index do |row, i|
next if i < 3 next if i < 3
v = row.cells.first.value v = row.cells.first.value rescue nil
next if v == "" || v.nil? next if v.blank?
import_this_image(row, album) import_this_image(row, album)
end end
redirect_to admin_gallery_path(album.id) redirect_to admin_gallery_path(album.id)

View File

@ -3,15 +3,14 @@ module Admin::GalleriesHelper
value = {} value = {}
image = AlbumImage.new image = AlbumImage.new
row.cells.each_with_index do |cell,index| row.cells.each_with_index do |cell,index|
next if cell.nil? val = cell.value rescue nil
val = cell.value next if val.blank?
next if val.nil? || val == ""
case index case index
when 0 when 0
image.remote_file_url = val image.remote_file_url = val
when 1 when 1
value["zh_tw"] = val value["zh_tw"] = val
value["en"] = row.cells[index + 1].value rescue "" value["en"] = (row.cells[index + 1].value rescue "")
image.description_translations = value image.description_translations = value
end end
end end