9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'app/models/concerns/active_admin_multi_upload/uploadable.rb', line 9
def allows_upload(name)
code = <<-eoruby
def to_jq_upload
uploader = send("#{name}")
thumb_url = uploader.respond_to?(:thumb) ? uploader.thumb.url : ""
{
"name" => uploader.filename,
"size" => uploader.size,
"url" => uploader.url,
"thumbnail_url" => thumb_url,
"delete_url" => destroy_upload_admin_#{self.name.underscore}_url(self, only_path: true),
"id" => id,
"delete_type" => "DELETE"
}
end
eoruby
class_eval(code)
end
|