回答編集履歴

5

うーん

2017/02/25 01:32

投稿

moke
moke

スコア2241

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

2017/02/25 01:32

投稿

moke
moke

スコア2241

test CHANGED
@@ -58,9 +58,9 @@
58
58
 
59
59
  ~
60
60
 
61
+ <%= f.fields_for :images_attributes do |image| %>
61
62
 
62
-
63
- <%= f.file_field :image,class: 'file-upload', :multiple => true ,name: "shop[images_attributes][][file]",'data-json'=>file_input_jbuilder(f.object.images) %>
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

すみません

2017/02/24 14:36

投稿

moke
moke

スコア2241

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"=>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

修正

2017/02/24 14:16

投稿

moke
moke

スコア2241

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

修正

2017/02/24 02:24

投稿

moke
moke

スコア2241

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