fix upload image error

This commit is contained in:
chiu 2021-04-19 09:36:27 +08:00
parent 5cd65d997f
commit f150f95379
2 changed files with 23 additions and 1 deletions

View File

@ -39,7 +39,7 @@ class Admin::RulingTemplatesController < OrbitAdminController
image = TemplateImageFile.new(template_image_params)
image.order = (template.template_image_files.max(:order) + 1 rescue 0)
image.r_template = template
image.save
image.save!
render :json => {"files" => [{"thumbnail_url"=>image.image_file.thumb.url}]}.to_json
end

View File

@ -1,4 +1,5 @@
class TemplateImageFile
require "ostruct"
include Mongoid::Document
include Mongoid::Timestamps
@ -7,4 +8,25 @@ class TemplateImageFile
field :order, :type => Integer, :default => 0
belongs_to :r_template
def album_crops
[]
end
def file
self.image_file
end
def album
tmp = OpenStruct.new
tmp.album_colors = album_colors
tmp.resize_gravity = 'Center'
tmp
end
def album_id
nil
end
def album_colors
[{'color' => 'transparent'}]
end
end