質問編集履歴
3
javascriptの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -246,7 +246,97 @@
|
|
246
246
|
|
247
247
|
```
|
248
248
|
|
249
|
-
|
249
|
+
```javascript
|
250
|
+
|
251
|
+
if (document.URL.match( /new/ ) ) {
|
252
|
+
|
253
|
+
document.addEventListener('DOMContentLoaded', function(){
|
254
|
+
|
255
|
+
const ImageList = document.getElementById('image-list');
|
256
|
+
|
257
|
+
|
258
|
+
|
259
|
+
|
260
|
+
|
261
|
+
const createImageHTML = (blob) => {
|
262
|
+
|
263
|
+
const imageElement = document.createElement('div');
|
264
|
+
|
265
|
+
imageElement.setAttribute('class', "image-element")
|
266
|
+
|
267
|
+
let imageElementNum = document.querySelectorAll('.image-element').length
|
268
|
+
|
269
|
+
|
270
|
+
|
271
|
+
|
272
|
+
|
273
|
+
|
274
|
+
|
275
|
+
const blobImage = document.createElement('img');
|
276
|
+
|
277
|
+
|
278
|
+
|
279
|
+
blobImage.setAttribute('src', blob);
|
280
|
+
|
281
|
+
|
282
|
+
|
283
|
+
const inputHTML = document.createElement('input')
|
284
|
+
|
285
|
+
inputHTML.setAttribute('id', `post_image_${imageElementNum}`)
|
286
|
+
|
287
|
+
inputHTML.setAttribute('name', 'post[images][]')
|
288
|
+
|
289
|
+
inputHTML.setAttribute('type', 'file')
|
290
|
+
|
291
|
+
|
292
|
+
|
293
|
+
|
294
|
+
|
295
|
+
imageElement.appendChild(blobImage);
|
296
|
+
|
297
|
+
imageElement.appendChild(inputHTML)
|
298
|
+
|
299
|
+
ImageList.appendChild(imageElement);
|
300
|
+
|
301
|
+
inputHTML.addEventListener('change', (e) => {
|
302
|
+
|
303
|
+
file = e.target.files[0];
|
304
|
+
|
305
|
+
blob = window.URL.createObjectURL(file);
|
306
|
+
|
307
|
+
|
308
|
+
|
309
|
+
createImageHTML(blob)
|
310
|
+
|
311
|
+
})
|
312
|
+
|
313
|
+
};
|
314
|
+
|
315
|
+
|
316
|
+
|
317
|
+
document.getElementById('post-image').addEventListener('change', function(e){
|
318
|
+
|
319
|
+
|
320
|
+
|
321
|
+
|
322
|
+
|
323
|
+
|
324
|
+
|
325
|
+
const file = e.target.files[0];
|
326
|
+
|
327
|
+
const blob = window.URL.createObjectURL(file);
|
328
|
+
|
329
|
+
|
330
|
+
|
331
|
+
createImageHTML(blob);
|
332
|
+
|
333
|
+
});
|
334
|
+
|
335
|
+
});
|
336
|
+
|
337
|
+
}
|
338
|
+
|
339
|
+
```
|
250
340
|
|
251
341
|
### 試したこと
|
252
342
|
|
2
ビューファイファイルの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -72,6 +72,180 @@
|
|
72
72
|
|
73
73
|
```
|
74
74
|
|
75
|
+
```Ruby
|
76
|
+
|
77
|
+
div class="post-sell-contents">
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
<div class="post-sell-main">
|
84
|
+
|
85
|
+
<h2 class="post-sell-title">コーデディネイトの情報を入力</h2>
|
86
|
+
|
87
|
+
<%= form_with model:@posts,url:posts_path,local: true do |f| %>
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
<%= render 'shared/error_messages', model: f.object%>
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
<%# 投稿画像 %>
|
100
|
+
|
101
|
+
<div class="img-upload">
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
<div class="weight-bold-text">
|
106
|
+
|
107
|
+
コーディネイト画像
|
108
|
+
|
109
|
+
<span class="indispensable">必須</span>
|
110
|
+
|
111
|
+
</div>
|
112
|
+
|
113
|
+
<div class="click-upload">
|
114
|
+
|
115
|
+
<p>
|
116
|
+
|
117
|
+
クリックしてファイルをアップロード
|
118
|
+
|
119
|
+
</p>
|
120
|
+
|
121
|
+
<%= f.file_field :images,name: 'post[image][]', id:"post-image" %>
|
122
|
+
|
123
|
+
<div id="image-list"></div>
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
</div>
|
128
|
+
|
129
|
+
</div>
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
<%# /投稿画像 %>
|
134
|
+
|
135
|
+
<%# アイテム名 %>
|
136
|
+
|
137
|
+
<div class="new-items">
|
138
|
+
|
139
|
+
<div class="weight-bold-text">
|
140
|
+
|
141
|
+
アウター
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
</div>
|
146
|
+
|
147
|
+
<%= f.text_area :outer, class:"post-text", id:"post-name", placeholder:"アウター名", maxlength:"20" %>
|
148
|
+
|
149
|
+
<div class="new-items">
|
150
|
+
|
151
|
+
<div class="weight-bold-text">
|
152
|
+
|
153
|
+
トップス
|
154
|
+
|
155
|
+
<span class="indispensable">必須</span>
|
156
|
+
|
157
|
+
</div>
|
158
|
+
|
159
|
+
<%= f.text_area :tops, class:"post-text", id:"post-name", placeholder:"トップス名", maxlength:"20" %>
|
160
|
+
|
161
|
+
<div class="new-items">
|
162
|
+
|
163
|
+
<div class="weight-bold-text">
|
164
|
+
|
165
|
+
パンツ
|
166
|
+
|
167
|
+
<span class="indispensable">必須</span>
|
168
|
+
|
169
|
+
</div>
|
170
|
+
|
171
|
+
<%= f.text_area :pants, class:"post-text", id:"post-name", placeholder:"パンツ名", maxlength:"20" %>
|
172
|
+
|
173
|
+
<div class="new-items">
|
174
|
+
|
175
|
+
<div class="weight-bold-text">
|
176
|
+
|
177
|
+
靴
|
178
|
+
|
179
|
+
<span class="indispensable">必須</span>
|
180
|
+
|
181
|
+
</div>
|
182
|
+
|
183
|
+
<%= f.text_area :shoes, class:"post-text", id:"post-name", placeholder:"靴名", maxlength:"20" %>
|
184
|
+
|
185
|
+
<div class="new-items">
|
186
|
+
|
187
|
+
<div class="weight-bold-text">
|
188
|
+
|
189
|
+
帽子
|
190
|
+
|
191
|
+
</div>
|
192
|
+
|
193
|
+
<%= f.text_area :hat, class:"post-text", id:"post-name", placeholder:"帽子名", maxlength:"20" %>
|
194
|
+
|
195
|
+
<div class="new-items">
|
196
|
+
|
197
|
+
<div class="weight-bold-text">
|
198
|
+
|
199
|
+
アクセサリー
|
200
|
+
|
201
|
+
</div>
|
202
|
+
|
203
|
+
<%= f.text_area :accessory, class:"post-text", id:"post-name", placeholder:"アクセサリー名", maxlength:"20" %>
|
204
|
+
|
205
|
+
<div class='new-items'>
|
206
|
+
|
207
|
+
<div class="weight-bold-text">
|
208
|
+
|
209
|
+
季節
|
210
|
+
|
211
|
+
<span class="indispensable">必須</span>
|
212
|
+
|
213
|
+
</div>
|
214
|
+
|
215
|
+
<%= f.collection_select(:season_id,Season.all,:id,:name,{},{class:"post-text", id:"post-season-fee-status"}) %>
|
216
|
+
|
217
|
+
</div>
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
|
222
|
+
|
223
|
+
<%# /配送について %>
|
224
|
+
|
225
|
+
|
226
|
+
|
227
|
+
|
228
|
+
|
229
|
+
|
230
|
+
|
231
|
+
<%# 下部ボタン %>
|
232
|
+
|
233
|
+
<div class="sell-btn-contents">
|
234
|
+
|
235
|
+
<%= f.submit "投稿する" ,class:"sell-btn",id: "subit" %>
|
236
|
+
|
237
|
+
<%=link_to 'もどる', root_path, class:"back-btn" %>
|
238
|
+
|
239
|
+
</div>
|
240
|
+
|
241
|
+
<%# /下部ボタン %>
|
242
|
+
|
243
|
+
|
244
|
+
|
245
|
+
<% end %>
|
246
|
+
|
247
|
+
```
|
248
|
+
|
75
249
|
|
76
250
|
|
77
251
|
### 試したこと
|
1
文法の修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -12,13 +12,17 @@
|
|
12
12
|
|
13
13
|
|
14
14
|
|
15
|
-
```
|
15
|
+
```
|
16
16
|
|
17
|
+
SyntaxError
|
18
|
+
|
17
|
-
|
19
|
+
/Users/ryota/projects/fashion_app/app/controllers/posts_controller.rb:18: Invalid char `\x08' in expression
|
20
|
+
|
21
|
+
|
18
22
|
|
19
23
|
```
|
20
24
|
|
21
|
-
|
25
|
+
![イメージ説明](5109d1b715de553b370994d9d908d3a3.png)
|
22
26
|
|
23
27
|
### 該当のソースコード
|
24
28
|
|