質問編集履歴
5
個数のselectをnumber_fieldに変更しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -260,7 +260,7 @@
|
|
260
260
|
|
261
261
|
<div>
|
262
262
|
|
263
|
-
<%= f.number :stock, name: "property[gift][#{b.value}][stock]" %>
|
263
|
+
<%= f.number_field :stock, name: "property[gift][#{b.value}][stock]" %>
|
264
264
|
|
265
265
|
<%= f.text_field :remark, placeholder: "備考を入力" ,name: "property[gift][#{b.value}][remark] " %>
|
266
266
|
|
4
_gifts、コントローラー修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -250,43 +250,25 @@
|
|
250
250
|
|
251
251
|
<span class="card-header">譲渡品</span>
|
252
252
|
|
253
|
-
<% @num = 1..50 %>
|
254
|
-
|
255
253
|
|
256
254
|
|
257
255
|
<div class="rounded card-body p-3 m-3 acc-table-innner" id="acc_chk">
|
258
256
|
|
259
|
-
<%= f.fields_for :gifts do |gift| %>
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
<% @mom = Accessory.all %>
|
264
|
-
|
265
|
-
<%=
|
257
|
+
<%= f.collection_check_boxes(:accessory_ids, Accessory.all, :id, :name, include_hidden: false) do |b| %>
|
266
258
|
|
267
259
|
<%= b.label { b.check_box + b.text } %>
|
268
260
|
|
269
|
-
|
261
|
+
<div>
|
270
|
-
|
262
|
+
|
271
|
-
|
263
|
+
<%= f.number :stock, name: "property[gift][#{b.value}][stock]" %>
|
272
|
-
|
273
|
-
|
274
|
-
|
264
|
+
|
275
|
-
|
265
|
+
<%= f.text_field :remark, placeholder: "備考を入力" ,name: "property[gift][#{b.value}][remark] " %>
|
276
|
-
|
266
|
+
|
277
|
-
|
267
|
+
</div>
|
278
|
-
|
279
|
-
|
280
|
-
|
268
|
+
|
269
|
+
|
270
|
+
|
281
|
-
|
271
|
+
<% end %>
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
<% end %>
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
272
|
|
291
273
|
|
292
274
|
|
@@ -294,8 +276,6 @@
|
|
294
276
|
|
295
277
|
</div>
|
296
278
|
|
297
|
-
|
298
|
-
|
299
279
|
```
|
300
280
|
|
301
281
|
|
@@ -316,12 +296,34 @@
|
|
316
296
|
|
317
297
|
if @property.save!
|
318
298
|
|
299
|
+
|
300
|
+
|
301
|
+
# ギフト作成
|
302
|
+
|
303
|
+
params[:property][:accessory_ids].each do | accessory_id |
|
304
|
+
|
305
|
+
@property.gifts.create(
|
306
|
+
|
307
|
+
accessory_id: accessory_id,
|
308
|
+
|
309
|
+
stock: params[:property][:gift][accessory_id][:stock],
|
310
|
+
|
311
|
+
remark: params[:property][:gift][accessory_id][:remark]
|
312
|
+
|
313
|
+
)
|
314
|
+
|
315
|
+
end
|
316
|
+
|
317
|
+
|
318
|
+
|
319
319
|
params[:property_images][:image].each do |image|
|
320
320
|
|
321
321
|
@property.property_images.create!(image: image, property_id: @property.id)
|
322
322
|
|
323
323
|
end
|
324
324
|
|
325
|
+
|
326
|
+
|
325
327
|
flash.now[:alert] = "#{@property.title}を作成しました。"
|
326
328
|
|
327
329
|
redirect_to property_new_path
|
@@ -356,7 +358,7 @@
|
|
356
358
|
|
357
359
|
:inu_or_suke, :end_on, :image,
|
358
360
|
|
359
|
-
area_tag_ids: [],category_ids: [],
|
361
|
+
area_tag_ids: [],category_ids: [],
|
360
362
|
|
361
363
|
preperty_images_attributes: [:image, :id, :_destroy]).merge(user_id: current.id)
|
362
364
|
|
3
再度修正しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -54,479 +54,253 @@
|
|
54
54
|
|
55
55
|
_form.html.erb
|
56
56
|
|
57
|
-
|
58
|
-
|
59
57
|
<%= form_with model:property, url:properties_path, local:true do |f| %>
|
60
58
|
|
59
|
+
|
60
|
+
|
61
|
-
<div class="container">
|
61
|
+
<div class="container">
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
62
|
+
|
63
|
+
|
64
|
+
|
69
|
-
<div class="row create-property-forms">
|
65
|
+
<div class="row create-property-forms">
|
70
|
-
|
66
|
+
|
71
|
-
<div class="col-7">
|
67
|
+
<div class="col-7">
|
72
|
-
|
73
|
-
|
74
|
-
|
68
|
+
|
69
|
+
|
70
|
+
|
75
|
-
<div class="card">
|
71
|
+
<div class="card">
|
72
|
+
|
76
|
-
|
73
|
+
<div class="card-header bg-gray">物件情報</div>
|
74
|
+
|
77
|
-
<div class="card-
|
75
|
+
<div class="card-body">
|
78
|
-
|
76
|
+
|
79
|
-
|
77
|
+
<!-- 基本情報 -->
|
78
|
+
|
79
|
+
<%= render :partial => "standard", :locals => { f: f } %>
|
80
|
+
|
81
|
+
<!-- テキストエリア -->
|
82
|
+
|
83
|
+
<%= render :partial => "textareas", :locals => { f: f } %>
|
84
|
+
|
85
|
+
<!-- 掲載期限 -->
|
86
|
+
|
87
|
+
<%= render :partial => "pereod", :locals => { f: f } %>
|
88
|
+
|
89
|
+
</div><!--左半分-->
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
<div class="col-5">
|
94
|
+
|
95
|
+
<!-- 業態 -->
|
96
|
+
|
97
|
+
<%= render :partial => "business_lists", :locals => { f: f} %>
|
98
|
+
|
99
|
+
<!-- エリア -->
|
100
|
+
|
101
|
+
<%= render :partial => "area", :locals => { f: f} %>
|
102
|
+
|
103
|
+
<!-- 譲渡品 -->
|
104
|
+
|
105
|
+
<%= render :partial => "gifts", :locals => { f: f} %>
|
106
|
+
|
107
|
+
</div><!--右半分-->
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
</div><!--全体ラップ-->
|
112
|
+
|
113
|
+
</div><!--container-->
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
<div class="container">
|
118
|
+
|
119
|
+
<!-- トップ画像 -->
|
120
|
+
|
121
|
+
<%= render :partial => "top_image", :locals => { f: f} %>
|
122
|
+
|
123
|
+
<!-- 複数画像 -->
|
124
|
+
|
125
|
+
<%= render :partial => "many_image", :locals => { f: f} %>
|
126
|
+
|
127
|
+
</div>
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
<!-- 追従 -->
|
132
|
+
|
133
|
+
<div class="fixed-box">
|
134
|
+
|
135
|
+
<div class="container">
|
136
|
+
|
137
|
+
<div class="d-flex justify-content-between">
|
138
|
+
|
139
|
+
<div class="">
|
140
|
+
|
141
|
+
<div class="secret-check">
|
142
|
+
|
143
|
+
<label for="secret_check" name="会員のみ公開" class="text-white">
|
144
|
+
|
145
|
+
<%= f.check_box :secret, cheked:true, id:"secret_check" %>
|
146
|
+
|
147
|
+
会員のみ公開</label>
|
148
|
+
|
149
|
+
</div>
|
150
|
+
|
151
|
+
<div class="recommend-check">
|
152
|
+
|
153
|
+
<label for="recommend_check" name="おすすめに表示する" class="text-white">
|
154
|
+
|
155
|
+
<%= f.check_box :recommend, cheked:true, id:"recommend_check" %>
|
156
|
+
|
157
|
+
おすすめに表示する</label>
|
158
|
+
|
159
|
+
</div>
|
160
|
+
|
161
|
+
</div>
|
162
|
+
|
163
|
+
<div class="my-2"><%= f.submit "登録", class:"btn btn-primary px-5 fixed-submit" %></div>
|
164
|
+
|
165
|
+
</div>
|
80
166
|
|
81
167
|
</div>
|
82
168
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
169
|
+
</div>
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
<% end %><!-- formend -->
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
<style media="screen">
|
178
|
+
|
179
|
+
.last-margin {
|
180
|
+
|
181
|
+
margin-bottom: 10rem!important;
|
182
|
+
|
183
|
+
}
|
184
|
+
|
185
|
+
.station_select {
|
186
|
+
|
187
|
+
width: 200px;
|
188
|
+
|
189
|
+
}
|
190
|
+
|
191
|
+
</style>
|
192
|
+
|
193
|
+
|
194
|
+
|
195
|
+
|
196
|
+
|
197
|
+
|
198
|
+
|
199
|
+
<script type="text/javascript">
|
200
|
+
|
201
|
+
|
202
|
+
|
203
|
+
$(document).ready(function(){
|
204
|
+
|
205
|
+
$('#property_pref').change(function(){
|
206
|
+
|
207
|
+
var pref_id = $('#property_pref') .val();
|
208
|
+
|
209
|
+
$.get("/properties/city",
|
210
|
+
|
211
|
+
{pref_id: pref_id},
|
212
|
+
|
213
|
+
function(data){}
|
214
|
+
|
215
|
+
);
|
216
|
+
|
217
|
+
})
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
$('#property_pref').change(function(){
|
222
|
+
|
223
|
+
var pref_id = $('#property_pref') .val();
|
224
|
+
|
225
|
+
$.get("/properties/station",
|
226
|
+
|
227
|
+
{pref_id: pref_id},
|
228
|
+
|
229
|
+
function(data){}
|
230
|
+
|
231
|
+
);
|
232
|
+
|
233
|
+
})
|
234
|
+
|
235
|
+
});
|
236
|
+
|
237
|
+
|
238
|
+
|
239
|
+
</script>
|
240
|
+
|
241
|
+
```
|
242
|
+
|
243
|
+
|
244
|
+
|
245
|
+
```gifts
|
246
|
+
|
247
|
+
_gifts.html.erb
|
248
|
+
|
249
|
+
<div class="card my-2">
|
250
|
+
|
251
|
+
<span class="card-header">譲渡品</span>
|
252
|
+
|
253
|
+
<% @num = 1..50 %>
|
254
|
+
|
255
|
+
|
256
|
+
|
257
|
+
<div class="rounded card-body p-3 m-3 acc-table-innner" id="acc_chk">
|
258
|
+
|
259
|
+
<%= f.fields_for :gifts do |gift| %>
|
260
|
+
|
261
|
+
|
262
|
+
|
263
|
+
<% @mom = Accessory.all %>
|
264
|
+
|
265
|
+
<%= gift.collection_check_boxes :accessory_id, Accessory.all, :id, :name, include_hidden: false do |b| %>
|
266
|
+
|
267
|
+
<%= b.label { b.check_box + b.text } %>
|
268
|
+
|
269
|
+
<div>
|
270
|
+
|
271
|
+
<%= gift.select :stock, @num, {include_blank: '個数を入力'} %>
|
272
|
+
|
273
|
+
|
274
|
+
|
275
|
+
<%= gift.text_field :remark, placeholder: "備考を入力" %>
|
276
|
+
|
277
|
+
</div>
|
278
|
+
|
279
|
+
|
280
|
+
|
281
|
+
<% end %>
|
282
|
+
|
283
|
+
|
118
284
|
|
119
285
|
<% end %>
|
120
286
|
|
121
|
-
|
287
|
+
|
122
|
-
|
123
|
-
|
288
|
+
|
124
|
-
|
125
|
-
|
289
|
+
|
126
|
-
|
127
|
-
|
290
|
+
|
128
|
-
|
129
|
-
|
291
|
+
|
130
292
|
|
131
293
|
</div>
|
132
294
|
|
133
|
-
</div>
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
<!-- 業態 -->
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
<!-- エリア -->
|
148
|
-
|
149
|
-
<div class="card my-2">
|
150
|
-
|
151
|
-
<span class="card-header">業態情報</span>
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
<div class="card-body">
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
<% if @property.errors.full_messages_for(:area_tag_list) %>
|
160
|
-
|
161
|
-
<% @property.errors.full_messages_for(:area_tag_list).each do |n| %>
|
162
|
-
|
163
|
-
<div class="err-mess"><%= n %></div>
|
164
|
-
|
165
|
-
<% end %>
|
166
|
-
|
167
|
-
<% end %>
|
168
|
-
|
169
|
-
<div class="category-list border rounded p-3 m-3">
|
170
|
-
|
171
|
-
<%= f.collection_check_boxes(:area_tag_ids, AreaTag.all, :id, :name, include_hidden: false) do |area| %>
|
172
|
-
|
173
|
-
<div><%= area.label { area.check_box + area.text } %></div>
|
174
|
-
|
175
|
-
<% end %>
|
176
|
-
|
177
|
-
</div>
|
178
|
-
|
179
295
|
</div>
|
180
296
|
|
181
|
-
|
297
|
+
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
298
|
+
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
<!-- 譲渡品 -->
|
196
|
-
|
197
|
-
<div class="card my-2">
|
198
|
-
|
199
|
-
<span class="card-header">譲渡品</span>
|
200
|
-
|
201
|
-
<% @num = 1..50 %>
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
<div class="rounded card-body p-3 m-3 acc-table-innner" id="acc_chk">
|
206
|
-
|
207
|
-
<%=f.fields_for :gifts do |ff| %>
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
<%= ff.collection_check_boxes :accessory_id, Accessory.all, :id, :name do |b| %>
|
212
|
-
|
213
|
-
<%= b.label { b.check_box + b.text } %>
|
214
|
-
|
215
|
-
<div class="add">
|
216
|
-
|
217
|
-
<%= ff.select :stock, @num, {include_blank: "個数を入力"} %>
|
218
|
-
|
219
|
-
<%= ff.text_field :remark %>
|
220
|
-
|
221
|
-
</div>
|
222
|
-
|
223
|
-
<% end %>
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
<% end %><!--fields_for-->
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
</div>
|
232
|
-
|
233
|
-
</div>
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
</div><!--右半分-->
|
246
|
-
|
247
|
-
</div><!--全体ラップ-->
|
248
|
-
|
249
|
-
</div><!--container-->
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
<!--画像-->
|
254
|
-
|
255
|
-
<div class="container">
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
<!-- 画像関連 -->
|
260
|
-
|
261
|
-
<!-- トップ画像 -->
|
262
|
-
|
263
|
-
<div class="card my-3">
|
264
|
-
|
265
|
-
<div class="card-header" data-toggle="tooltip" title="物件一覧に表示される画像となります">
|
266
|
-
|
267
|
-
<%= f.label :トップ画像 %>
|
268
|
-
|
269
|
-
<%= fa_icon("question",class:"fa fa-question-circle fa-lg ml-1") %>
|
270
|
-
|
271
|
-
</div>
|
272
|
-
|
273
|
-
<div class="card-body">
|
274
|
-
|
275
|
-
<div class="row">
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
<div class="col-6">
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
<div class="filearea-box my-4">
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
<p class="small">画像をドラッグ&ドロップまたは</p>
|
290
|
-
|
291
|
-
<%= f.file_field :image , onchange: 'photoPreview(event)',id: "fileInput", class:"filearea" %>
|
292
|
-
|
293
|
-
</div>
|
294
|
-
|
295
|
-
</div>
|
296
|
-
|
297
|
-
<div class="col-6">
|
298
|
-
|
299
|
-
<div class="">
|
300
|
-
|
301
|
-
<span class="small">トップ画像プレビュー</span>
|
302
|
-
|
303
|
-
<div class="card-body">
|
304
|
-
|
305
|
-
<div id="previewArea"></div>
|
306
|
-
|
307
|
-
</div>
|
308
|
-
|
309
|
-
</div>
|
310
|
-
|
311
|
-
</div>
|
312
|
-
|
313
|
-
</div>
|
314
|
-
|
315
|
-
</div>
|
316
|
-
|
317
|
-
</div>
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
<!-- トップ画像(プレビュー) -->
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
<%= f.fields_for :property_images do |img| %>
|
328
|
-
|
329
|
-
<!-- 複数画像 -->
|
330
|
-
|
331
|
-
<div class="card my-3 last-margin">
|
332
|
-
|
333
|
-
<div class="card-header" data-toggle="tooltip" title="物件詳細のスライドショーに表示される画像になります">
|
334
|
-
|
335
|
-
<%= img.label :物件画像 %><br><span class="small">(複数画像選択できます)</span>
|
336
|
-
|
337
|
-
<%= fa_icon("question",class:"fa fa-question-circle fa-lg ml-1") %>
|
338
|
-
|
339
|
-
</div>
|
340
|
-
|
341
|
-
<div class="card-body">
|
342
|
-
|
343
|
-
<div class="row">
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
<div class="col-6">
|
348
|
-
|
349
|
-
<div class="filearea-box my-4">
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
<% if @property.errors.full_messages_for(:property_images) %>
|
354
|
-
|
355
|
-
<% @property.errors.full_messages_for(:property_images).each do |n| %>
|
356
|
-
|
357
|
-
<div class="err-mess"><%= n %></div>
|
358
|
-
|
359
|
-
<% end %>
|
360
|
-
|
361
|
-
<% end %>
|
362
|
-
|
363
|
-
<p class="small">画像をドラッグ&ドロップまたは</p>
|
364
|
-
|
365
|
-
<input type="file" name="property_images[image][]" id="property_images[image][]" accept="image/*" multiple data-target="#file1-image">
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
</div>
|
370
|
-
|
371
|
-
</div>
|
372
|
-
|
373
|
-
<div class="col-6">
|
374
|
-
|
375
|
-
<div class="">
|
376
|
-
|
377
|
-
<p class="small">スライド画像プレビュー</p>
|
378
|
-
|
379
|
-
<div class="card-body">
|
380
|
-
|
381
|
-
<div id="preview" class="">
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
</div>
|
386
|
-
|
387
|
-
</div>
|
388
|
-
|
389
|
-
</div>
|
390
|
-
|
391
|
-
</div>
|
392
|
-
|
393
|
-
</div>
|
394
|
-
|
395
|
-
</div>
|
396
|
-
|
397
|
-
</div>
|
398
|
-
|
399
|
-
<% end %>
|
400
|
-
|
401
|
-
<!-- 複数画像プレビュー -->
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
<!-- 画像関連 -->
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
</div>
|
412
|
-
|
413
|
-
<!--画像-->
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
<!-- 追従 -->
|
422
|
-
|
423
|
-
<div class="fixed-box">
|
424
|
-
|
425
|
-
<div class="container">
|
426
|
-
|
427
|
-
<div class="d-flex justify-content-between">
|
428
|
-
|
429
|
-
<div class="">
|
430
|
-
|
431
|
-
<div class="secret-check">
|
432
|
-
|
433
|
-
<label for="secret_check" name="会員のみ公開" class="text-white">
|
434
|
-
|
435
|
-
<%= f.check_box :secret, cheked:true, id:"secret_check" %>
|
436
|
-
|
437
|
-
会員のみ公開</label>
|
438
|
-
|
439
|
-
</div>
|
440
|
-
|
441
|
-
<div class="recommend-check">
|
442
|
-
|
443
|
-
<label for="recommend_check" name="おすすめに表示する" class="text-white">
|
444
|
-
|
445
|
-
<%= f.check_box :recommend, cheked:true, id:"recommend_check" %>
|
446
|
-
|
447
|
-
おすすめに表示する</label>
|
448
|
-
|
449
|
-
</div>
|
450
|
-
|
451
|
-
</div>
|
452
|
-
|
453
|
-
<div class="my-2"><%= f.submit "登録", class:"btn btn-primary px-5 fixed-submit" %></div>
|
454
|
-
|
455
|
-
</div>
|
456
|
-
|
457
|
-
</div>
|
458
|
-
|
459
|
-
</div>
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
<% end %>
|
464
|
-
|
465
|
-
<style media="screen">
|
466
|
-
|
467
|
-
.last-margin {
|
468
|
-
|
469
|
-
margin-bottom: 10rem!important;
|
470
|
-
|
471
|
-
}
|
472
|
-
|
473
|
-
.station_select {
|
474
|
-
|
475
|
-
width: 200px;
|
476
|
-
|
477
|
-
}
|
478
|
-
|
479
|
-
</style>
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
<script type="text/javascript">
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
$(document).ready(function(){
|
492
|
-
|
493
|
-
$('#property_pref').change(function(){
|
494
|
-
|
495
|
-
var pref_id = $('#property_pref') .val();
|
496
|
-
|
497
|
-
$.get("/properties/city",
|
498
|
-
|
499
|
-
{pref_id: pref_id},
|
500
|
-
|
501
|
-
function(data){}
|
502
|
-
|
503
|
-
);
|
504
|
-
|
505
|
-
})
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
$('#property_pref').change(function(){
|
510
|
-
|
511
|
-
var pref_id = $('#property_pref') .val();
|
512
|
-
|
513
|
-
$.get("/properties/station",
|
514
|
-
|
515
|
-
{pref_id: pref_id},
|
516
|
-
|
517
|
-
function(data){}
|
518
|
-
|
519
|
-
);
|
520
|
-
|
521
|
-
})
|
522
|
-
|
523
|
-
});
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
</script>
|
528
|
-
|
529
|
-
```
|
299
|
+
```
|
300
|
+
|
301
|
+
|
302
|
+
|
303
|
+
|
530
304
|
|
531
305
|
|
532
306
|
|
2
情報が不十分で申し訳ございません。追記編集いたしました。フォームの送り先のコントローラーは追記コントローラーのcreateにいくのでそちらと、ストロングパラメーターも入れています。
test
CHANGED
File without changes
|
test
CHANGED
@@ -30,7 +30,7 @@
|
|
30
30
|
|
31
31
|
```gift
|
32
32
|
|
33
|
-
belongs_to :
|
33
|
+
belongs_to :property, optional: true
|
34
34
|
|
35
35
|
belongs_to :accessory, optional: true
|
36
36
|
|
@@ -40,7 +40,7 @@
|
|
40
40
|
|
41
41
|
has_many :gifts
|
42
42
|
|
43
|
-
has_many :i
|
43
|
+
has_many :properties, through: :gifts
|
44
44
|
|
45
45
|
|
46
46
|
|
@@ -50,6 +50,150 @@
|
|
50
50
|
|
51
51
|
```form
|
52
52
|
|
53
|
+
|
54
|
+
|
55
|
+
_form.html.erb
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
<%= form_with model:property, url:properties_path, local:true do |f| %>
|
60
|
+
|
61
|
+
<div class="container">
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
<div class="row create-property-forms">
|
70
|
+
|
71
|
+
<div class="col-7">
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
<div class="card">
|
76
|
+
|
77
|
+
<div class="card-header bg-gray">
|
78
|
+
|
79
|
+
物件情報
|
80
|
+
|
81
|
+
</div>
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
=======================================
|
86
|
+
|
87
|
+
こちらに他カラム記入フォームがあるのですが、文字数制限の為割愛
|
88
|
+
|
89
|
+
=======================================
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
<div class="col-5">
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
<!-- 業態 -->
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
<div class="card">
|
102
|
+
|
103
|
+
<span class="card-header">業態情報</span>
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
<div class="card-body">
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
<% if @property.errors.full_messages_for(:business_lists) %>
|
112
|
+
|
113
|
+
<% @property.errors.full_messages_for(:business_lists).each do |n| %>
|
114
|
+
|
115
|
+
<div class="err-mess"><%= n %></div>
|
116
|
+
|
117
|
+
<% end %>
|
118
|
+
|
119
|
+
<% end %>
|
120
|
+
|
121
|
+
<div class="category-list border rounded p-3 m-3">
|
122
|
+
|
123
|
+
<%= f.collection_check_boxes(:category_ids, Category.all, :id, :name, include_hidden: false) do |cat| %>
|
124
|
+
|
125
|
+
<div><%= cat.label { cat.check_box + cat.text } %></div>
|
126
|
+
|
127
|
+
<% end %>
|
128
|
+
|
129
|
+
</div>
|
130
|
+
|
131
|
+
</div>
|
132
|
+
|
133
|
+
</div>
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
<!-- 業態 -->
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
<!-- エリア -->
|
148
|
+
|
149
|
+
<div class="card my-2">
|
150
|
+
|
151
|
+
<span class="card-header">業態情報</span>
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
<div class="card-body">
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
<% if @property.errors.full_messages_for(:area_tag_list) %>
|
160
|
+
|
161
|
+
<% @property.errors.full_messages_for(:area_tag_list).each do |n| %>
|
162
|
+
|
163
|
+
<div class="err-mess"><%= n %></div>
|
164
|
+
|
165
|
+
<% end %>
|
166
|
+
|
167
|
+
<% end %>
|
168
|
+
|
169
|
+
<div class="category-list border rounded p-3 m-3">
|
170
|
+
|
171
|
+
<%= f.collection_check_boxes(:area_tag_ids, AreaTag.all, :id, :name, include_hidden: false) do |area| %>
|
172
|
+
|
173
|
+
<div><%= area.label { area.check_box + area.text } %></div>
|
174
|
+
|
175
|
+
<% end %>
|
176
|
+
|
177
|
+
</div>
|
178
|
+
|
179
|
+
</div>
|
180
|
+
|
181
|
+
</div>
|
182
|
+
|
183
|
+
|
184
|
+
|
185
|
+
|
186
|
+
|
187
|
+
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
<!-- エリア -->
|
192
|
+
|
193
|
+
|
194
|
+
|
195
|
+
<!-- 譲渡品 -->
|
196
|
+
|
53
197
|
<div class="card my-2">
|
54
198
|
|
55
199
|
<span class="card-header">譲渡品</span>
|
@@ -60,44 +204,394 @@
|
|
60
204
|
|
61
205
|
<div class="rounded card-body p-3 m-3 acc-table-innner" id="acc_chk">
|
62
206
|
|
63
|
-
<%=
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
207
|
+
<%=f.fields_for :gifts do |ff| %>
|
208
|
+
|
209
|
+
|
210
|
+
|
211
|
+
<%= ff.collection_check_boxes :accessory_id, Accessory.all, :id, :name do |b| %>
|
212
|
+
|
213
|
+
<%= b.label { b.check_box + b.text } %>
|
214
|
+
|
215
|
+
<div class="add">
|
216
|
+
|
217
|
+
<%= ff.select :stock, @num, {include_blank: "個数を入力"} %>
|
218
|
+
|
219
|
+
<%= ff.text_field :remark %>
|
220
|
+
|
221
|
+
</div>
|
222
|
+
|
223
|
+
<% end %>
|
224
|
+
|
225
|
+
|
226
|
+
|
227
|
+
<% end %><!--fields_for-->
|
228
|
+
|
229
|
+
|
230
|
+
|
231
|
+
</div>
|
232
|
+
|
233
|
+
</div>
|
234
|
+
|
235
|
+
|
236
|
+
|
237
|
+
|
238
|
+
|
239
|
+
|
240
|
+
|
241
|
+
|
242
|
+
|
243
|
+
|
244
|
+
|
245
|
+
</div><!--右半分-->
|
246
|
+
|
247
|
+
</div><!--全体ラップ-->
|
248
|
+
|
249
|
+
</div><!--container-->
|
250
|
+
|
251
|
+
|
252
|
+
|
253
|
+
<!--画像-->
|
254
|
+
|
255
|
+
<div class="container">
|
256
|
+
|
257
|
+
|
258
|
+
|
259
|
+
<!-- 画像関連 -->
|
260
|
+
|
261
|
+
<!-- トップ画像 -->
|
262
|
+
|
263
|
+
<div class="card my-3">
|
264
|
+
|
265
|
+
<div class="card-header" data-toggle="tooltip" title="物件一覧に表示される画像となります">
|
266
|
+
|
267
|
+
<%= f.label :トップ画像 %>
|
268
|
+
|
269
|
+
<%= fa_icon("question",class:"fa fa-question-circle fa-lg ml-1") %>
|
270
|
+
|
271
|
+
</div>
|
272
|
+
|
273
|
+
<div class="card-body">
|
274
|
+
|
275
|
+
<div class="row">
|
276
|
+
|
277
|
+
|
278
|
+
|
279
|
+
<div class="col-6">
|
280
|
+
|
281
|
+
|
282
|
+
|
283
|
+
|
284
|
+
|
285
|
+
<div class="filearea-box my-4">
|
286
|
+
|
287
|
+
|
288
|
+
|
289
|
+
<p class="small">画像をドラッグ&ドロップまたは</p>
|
290
|
+
|
291
|
+
<%= f.file_field :image , onchange: 'photoPreview(event)',id: "fileInput", class:"filearea" %>
|
292
|
+
|
293
|
+
</div>
|
294
|
+
|
295
|
+
</div>
|
296
|
+
|
297
|
+
<div class="col-6">
|
298
|
+
|
299
|
+
<div class="">
|
300
|
+
|
301
|
+
<span class="small">トップ画像プレビュー</span>
|
302
|
+
|
303
|
+
<div class="card-body">
|
304
|
+
|
305
|
+
<div id="previewArea"></div>
|
306
|
+
|
307
|
+
</div>
|
308
|
+
|
309
|
+
</div>
|
310
|
+
|
311
|
+
</div>
|
312
|
+
|
313
|
+
</div>
|
314
|
+
|
315
|
+
</div>
|
316
|
+
|
317
|
+
</div>
|
318
|
+
|
319
|
+
|
320
|
+
|
321
|
+
<!-- トップ画像(プレビュー) -->
|
322
|
+
|
323
|
+
|
324
|
+
|
325
|
+
|
326
|
+
|
327
|
+
<%= f.fields_for :property_images do |img| %>
|
328
|
+
|
329
|
+
<!-- 複数画像 -->
|
330
|
+
|
331
|
+
<div class="card my-3 last-margin">
|
332
|
+
|
333
|
+
<div class="card-header" data-toggle="tooltip" title="物件詳細のスライドショーに表示される画像になります">
|
334
|
+
|
335
|
+
<%= img.label :物件画像 %><br><span class="small">(複数画像選択できます)</span>
|
336
|
+
|
337
|
+
<%= fa_icon("question",class:"fa fa-question-circle fa-lg ml-1") %>
|
338
|
+
|
339
|
+
</div>
|
340
|
+
|
341
|
+
<div class="card-body">
|
342
|
+
|
343
|
+
<div class="row">
|
344
|
+
|
345
|
+
|
346
|
+
|
347
|
+
<div class="col-6">
|
348
|
+
|
349
|
+
<div class="filearea-box my-4">
|
350
|
+
|
351
|
+
|
352
|
+
|
353
|
+
<% if @property.errors.full_messages_for(:property_images) %>
|
354
|
+
|
355
|
+
<% @property.errors.full_messages_for(:property_images).each do |n| %>
|
356
|
+
|
357
|
+
<div class="err-mess"><%= n %></div>
|
80
358
|
|
81
359
|
<% end %>
|
82
360
|
|
83
|
-
|
84
|
-
|
85
|
-
<% end %>
|
361
|
+
<% end %>
|
362
|
+
|
86
|
-
|
363
|
+
<p class="small">画像をドラッグ&ドロップまたは</p>
|
364
|
+
|
87
|
-
|
365
|
+
<input type="file" name="property_images[image][]" id="property_images[image][]" accept="image/*" multiple data-target="#file1-image">
|
366
|
+
|
367
|
+
|
368
|
+
|
88
|
-
|
369
|
+
</div>
|
370
|
+
|
89
|
-
|
371
|
+
</div>
|
372
|
+
|
90
|
-
|
373
|
+
<div class="col-6">
|
374
|
+
|
91
|
-
|
375
|
+
<div class="">
|
376
|
+
|
377
|
+
<p class="small">スライド画像プレビュー</p>
|
378
|
+
|
379
|
+
<div class="card-body">
|
380
|
+
|
381
|
+
<div id="preview" class="">
|
382
|
+
|
383
|
+
|
384
|
+
|
385
|
+
</div>
|
386
|
+
|
387
|
+
</div>
|
388
|
+
|
389
|
+
</div>
|
390
|
+
|
391
|
+
</div>
|
92
392
|
|
93
393
|
</div>
|
94
394
|
|
95
395
|
</div>
|
96
396
|
|
397
|
+
</div>
|
398
|
+
|
399
|
+
<% end %>
|
400
|
+
|
401
|
+
<!-- 複数画像プレビュー -->
|
402
|
+
|
403
|
+
|
404
|
+
|
405
|
+
<!-- 画像関連 -->
|
406
|
+
|
407
|
+
|
408
|
+
|
409
|
+
|
410
|
+
|
411
|
+
</div>
|
412
|
+
|
413
|
+
<!--画像-->
|
414
|
+
|
415
|
+
|
416
|
+
|
417
|
+
|
418
|
+
|
419
|
+
|
420
|
+
|
421
|
+
<!-- 追従 -->
|
422
|
+
|
423
|
+
<div class="fixed-box">
|
424
|
+
|
425
|
+
<div class="container">
|
426
|
+
|
427
|
+
<div class="d-flex justify-content-between">
|
428
|
+
|
429
|
+
<div class="">
|
430
|
+
|
431
|
+
<div class="secret-check">
|
432
|
+
|
433
|
+
<label for="secret_check" name="会員のみ公開" class="text-white">
|
434
|
+
|
435
|
+
<%= f.check_box :secret, cheked:true, id:"secret_check" %>
|
436
|
+
|
437
|
+
会員のみ公開</label>
|
438
|
+
|
439
|
+
</div>
|
440
|
+
|
441
|
+
<div class="recommend-check">
|
442
|
+
|
443
|
+
<label for="recommend_check" name="おすすめに表示する" class="text-white">
|
444
|
+
|
445
|
+
<%= f.check_box :recommend, cheked:true, id:"recommend_check" %>
|
446
|
+
|
447
|
+
おすすめに表示する</label>
|
448
|
+
|
449
|
+
</div>
|
450
|
+
|
451
|
+
</div>
|
452
|
+
|
453
|
+
<div class="my-2"><%= f.submit "登録", class:"btn btn-primary px-5 fixed-submit" %></div>
|
454
|
+
|
455
|
+
</div>
|
456
|
+
|
457
|
+
</div>
|
458
|
+
|
459
|
+
</div>
|
460
|
+
|
461
|
+
|
462
|
+
|
463
|
+
<% end %>
|
464
|
+
|
465
|
+
<style media="screen">
|
466
|
+
|
467
|
+
.last-margin {
|
468
|
+
|
469
|
+
margin-bottom: 10rem!important;
|
470
|
+
|
471
|
+
}
|
472
|
+
|
473
|
+
.station_select {
|
474
|
+
|
475
|
+
width: 200px;
|
476
|
+
|
477
|
+
}
|
478
|
+
|
479
|
+
</style>
|
480
|
+
|
481
|
+
|
482
|
+
|
483
|
+
|
484
|
+
|
485
|
+
|
486
|
+
|
487
|
+
<script type="text/javascript">
|
488
|
+
|
489
|
+
|
490
|
+
|
491
|
+
$(document).ready(function(){
|
492
|
+
|
493
|
+
$('#property_pref').change(function(){
|
494
|
+
|
495
|
+
var pref_id = $('#property_pref') .val();
|
496
|
+
|
497
|
+
$.get("/properties/city",
|
498
|
+
|
499
|
+
{pref_id: pref_id},
|
500
|
+
|
501
|
+
function(data){}
|
502
|
+
|
503
|
+
);
|
504
|
+
|
505
|
+
})
|
506
|
+
|
507
|
+
|
508
|
+
|
509
|
+
$('#property_pref').change(function(){
|
510
|
+
|
511
|
+
var pref_id = $('#property_pref') .val();
|
512
|
+
|
513
|
+
$.get("/properties/station",
|
514
|
+
|
515
|
+
{pref_id: pref_id},
|
516
|
+
|
517
|
+
function(data){}
|
518
|
+
|
519
|
+
);
|
520
|
+
|
521
|
+
})
|
522
|
+
|
523
|
+
});
|
524
|
+
|
525
|
+
|
526
|
+
|
527
|
+
</script>
|
528
|
+
|
97
529
|
```
|
98
530
|
|
99
531
|
|
100
532
|
|
533
|
+
```controller
|
534
|
+
|
535
|
+
def create
|
536
|
+
|
537
|
+
@property = Property.new(property_params)
|
538
|
+
|
539
|
+
|
540
|
+
|
541
|
+
respond_to do |format|
|
542
|
+
|
543
|
+
if @property.save!
|
544
|
+
|
545
|
+
params[:property_images][:image].each do |image|
|
546
|
+
|
547
|
+
@property.property_images.create!(image: image, property_id: @property.id)
|
548
|
+
|
549
|
+
end
|
550
|
+
|
551
|
+
flash.now[:alert] = "#{@property.title}を作成しました。"
|
552
|
+
|
553
|
+
redirect_to property_new_path
|
554
|
+
|
555
|
+
else
|
556
|
+
|
557
|
+
flash.now[:alert] = "物件作成に失敗しました"
|
558
|
+
|
559
|
+
format.html { render :new }
|
560
|
+
|
561
|
+
format.json { render json: @property.errors, status: :unprocessable_entity }
|
562
|
+
|
563
|
+
end
|
564
|
+
|
565
|
+
end
|
566
|
+
|
567
|
+
end
|
568
|
+
|
569
|
+
|
570
|
+
|
571
|
+
private
|
572
|
+
|
573
|
+
def property_params
|
574
|
+
|
575
|
+
params.require(:property).permit(:title, :preperty_no,:control_num,:price,:deposit,:admin_const,
|
576
|
+
|
577
|
+
:othoer_price,:facility,:street_address,:traffic,:age,:area,
|
578
|
+
|
579
|
+
:floor,:parcel,:construction,:parking,:parking_exp,:contract_method,:contract_period,:time,:secret,
|
580
|
+
|
581
|
+
:recommend,:current_status,:list_comment,:detail_comment,:recommend_comment, :pref ,:city, :station,
|
582
|
+
|
583
|
+
:inu_or_suke, :end_on, :image,
|
584
|
+
|
585
|
+
area_tag_ids: [],category_ids: [], gifts_attributes: [:property_id, :accessory_id, :stock, :remark],
|
586
|
+
|
587
|
+
preperty_images_attributes: [:image, :id, :_destroy]).merge(user_id: current.id)
|
588
|
+
|
589
|
+
end
|
590
|
+
|
591
|
+
```
|
592
|
+
|
593
|
+
|
594
|
+
|
101
595
|
イメージ図
|
102
596
|
|
103
597
|
![イメージ図](0ea72b6c1989a87c840702c5883a414f.jpeg)
|
1
実現したい事の補填
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
【Rails】チェックした
|
1
|
+
【Rails】チェックで選択した項目の個数と備考欄を付けて保存したい
|
test
CHANGED
@@ -1,16 +1,22 @@
|
|
1
|
-
|
1
|
+
- 前提・実現したいこと
|
2
2
|
|
3
|
-
|
3
|
+
Railsで物件登録システムを作っています。
|
4
4
|
|
5
|
+
物件を登録する時に既に作られているモデルをチェックボックスから選択してそのチェックした個数と備考欄を子テーブルとして登録したいです。
|
6
|
+
|
5
|
-
|
7
|
+
このような要件の場合、どのようにしてチェックしたものを他情報を添えて登録することができるのでしょうか。
|
8
|
+
|
9
|
+
ご教示頂けますと幸いです。
|
10
|
+
|
11
|
+
なお質問要件の前はチェックしたものと物件を紐づけるのみでしたので、中間テーブルとして登録していました。
|
12
|
+
|
13
|
+
その時のモデルファイルが以下になります。
|
6
14
|
|
7
15
|
|
8
16
|
|
9
17
|
__モデル__
|
10
18
|
|
11
|
-
```
|
19
|
+
```property
|
12
|
-
|
13
|
-
Item
|
14
20
|
|
15
21
|
has_many :gifts, :dependent => :destroy
|
16
22
|
|
@@ -22,9 +28,7 @@
|
|
22
28
|
|
23
29
|
|
24
30
|
|
25
|
-
```
|
26
|
-
|
27
|
-
|
31
|
+
```gift
|
28
32
|
|
29
33
|
belongs_to :item, optional: true
|
30
34
|
|
@@ -32,12 +36,68 @@
|
|
32
36
|
|
33
37
|
```
|
34
38
|
|
35
|
-
```
|
39
|
+
```accessory
|
36
|
-
|
37
|
-
Gift
|
38
40
|
|
39
41
|
has_many :gifts
|
40
42
|
|
41
43
|
has_many :items, through: :gifts
|
42
44
|
|
45
|
+
|
46
|
+
|
43
47
|
```
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
```form
|
52
|
+
|
53
|
+
<div class="card my-2">
|
54
|
+
|
55
|
+
<span class="card-header">譲渡品</span>
|
56
|
+
|
57
|
+
<% @num = 1..50 %>
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
<div class="rounded card-body p-3 m-3 acc-table-innner" id="acc_chk">
|
62
|
+
|
63
|
+
<%= f.fields_for :gifts do |gift| %>
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
<%= gift.collection_check_boxes :accessory_id, Accessory.all, :id, :name, include_hidden: false do |b| %>
|
68
|
+
|
69
|
+
<%= b.label { b.check_box + b.text } %>
|
70
|
+
|
71
|
+
<div>
|
72
|
+
|
73
|
+
<%= gift.select :stock, @num, {include_blank: '個数を入力'} %>
|
74
|
+
|
75
|
+
<%= gift.text_field :remark, placeholder: "備考を入力" %>
|
76
|
+
|
77
|
+
</div>
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
<% end %>
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
<% end %>
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
</div>
|
94
|
+
|
95
|
+
</div>
|
96
|
+
|
97
|
+
```
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
イメージ図
|
102
|
+
|
103
|
+
![イメージ図](0ea72b6c1989a87c840702c5883a414f.jpeg)
|