gallery/app/helpers/admin/galleries_helper.rb

21 lines
495 B
Ruby
Raw Normal View History

2014-05-01 07:06:48 +00:00
module Admin::GalleriesHelper
2016-12-20 11:43:54 +00:00
def import_this_image(row,album)
value = {}
image = AlbumImage.new
2021-03-30 07:52:09 +00:00
image.album = album
2016-12-20 11:43:54 +00:00
row.cells.each_with_index do |cell,index|
2021-03-30 07:45:22 +00:00
val = cell.value rescue nil
next if val.blank?
2016-12-20 11:43:54 +00:00
case index
when 0
image.remote_file_url = val
when 1
value["zh_tw"] = val
2021-03-30 07:45:22 +00:00
value["en"] = (row.cells[index + 1].value rescue "")
2016-12-20 11:43:54 +00:00
image.description_translations = value
end
end
image.save
end
2014-05-01 07:06:48 +00:00
end