fix error

This commit is contained in:
邱博亞 2021-03-30 15:27:20 +08:00
parent 7d12d71f14
commit 35d8843705
2 changed files with 6 additions and 5 deletions

View File

@ -130,8 +130,8 @@ class Admin::AnnouncementsController < OrbitAdminController
if sheet.count <= 503 if sheet.count <= 503
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_announcement(row, categories, tags) import_this_announcement(row, categories, tags)
end end
redirect_to admin_announcements_path redirect_to admin_announcements_path

View File

@ -33,9 +33,10 @@ module Admin::AnnouncementsHelper
value = {} value = {}
anns = Bulletin.new anns = Bulletin.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 if [8,9,10,11,12,13,14,15].exclude?(index)
next if val.nil? || val == "" next if val.blank?
end
case index case index
when 0 when 0
anns.category = categories[val.to_i] anns.category = categories[val.to_i]