回答編集履歴
5
うーん
test
CHANGED
@@ -88,6 +88,8 @@
|
|
88
88
|
|
89
89
|
def file_input_jbuilder(images)
|
90
90
|
|
91
|
+
images=Array(images)
|
92
|
+
|
91
93
|
({"initialPreview"=>images.map{|image|image.thumb.url},
|
92
94
|
|
93
95
|
"initialPreviewAsData"=>true,
|
4
Test
test
CHANGED
@@ -58,9 +58,9 @@
|
|
58
58
|
|
59
59
|
~
|
60
60
|
|
61
|
+
<%= f.fields_for :images_attributes do |image| %>
|
61
62
|
|
62
|
-
|
63
|
-
<%=
|
63
|
+
<%= image.file_field :file,class: 'file-upload',name: "#{image.object_name}[file]",'data-json'=>file_input_jbuilder(image.object.file) %>
|
64
64
|
|
65
65
|
<%= javascript_tag do %>
|
66
66
|
|
@@ -69,14 +69,6 @@
|
|
69
69
|
<% end %>
|
70
70
|
|
71
71
|
```
|
72
|
-
|
73
|
-
fields_for を使うときは
|
74
|
-
|
75
|
-
name: "shop[images_attributes][][file]"
|
76
|
-
|
77
|
-
を
|
78
|
-
|
79
|
-
name: "#{f.object_name}[images_attributes][][file]"
|
80
72
|
|
81
73
|
|
82
74
|
|
3
すみません
test
CHANGED
@@ -100,7 +100,7 @@
|
|
100
100
|
|
101
101
|
"initialPreviewAsData"=>true,
|
102
102
|
|
103
|
-
"initialPreviewConfig"=>a
|
103
|
+
"initialPreviewConfig"=>images.map{|image| {"caption"=>image.original_filename,"width"=> '120px',"url"=> url_for({controller: :images,action: :delete,id: image.id}),"key"=> 100}}}).to_json
|
104
104
|
|
105
105
|
end
|
106
106
|
|
2
修正
test
CHANGED
@@ -100,7 +100,7 @@
|
|
100
100
|
|
101
101
|
"initialPreviewAsData"=>true,
|
102
102
|
|
103
|
-
"initialPreviewConfig"=>attachments.map{|image| {"caption"=>image.original_filename,"width"=> '120px',"url"=> url_for{controller: :images,action: :delete,id: image.id},"key"=> 100}}}).to_json
|
103
|
+
"initialPreviewConfig"=>attachments.map{|image| {"caption"=>image.original_filename,"width"=> '120px',"url"=> url_for({controller: :images,action: :delete,id: image.id}),"key"=> 100}}}).to_json
|
104
104
|
|
105
105
|
end
|
106
106
|
|
1
修正
test
CHANGED
@@ -100,7 +100,7 @@
|
|
100
100
|
|
101
101
|
"initialPreviewAsData"=>true,
|
102
102
|
|
103
|
-
"initialPreviewConfig"=>attachments.map{|image| {"caption"=>image.original_filename,"width"=> '120px',"url"=> url_for{controller: :image,action: :delete,id: image.id},"key"=> 100}}}).to_json
|
103
|
+
"initialPreviewConfig"=>attachments.map{|image| {"caption"=>image.original_filename,"width"=> '120px',"url"=> url_for{controller: :images,action: :delete,id: image.id},"key"=> 100}}}).to_json
|
104
104
|
|
105
105
|
end
|
106
106
|
|