質問編集履歴
2
恐れ入ります、修正しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -36,16 +36,264 @@
|
|
36
36
|
|
37
37
|
accepts_nested_attributes_for :tickets, allow_destroy: true
|
38
38
|
|
39
|
-
|
39
|
+
```
|
40
|
+
|
41
|
+
```ruby
|
40
42
|
|
41
43
|
ticket.rb
|
42
44
|
|
43
45
|
belongs_to :event
|
44
46
|
|
45
|
-
|
47
|
+
```
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
```ruby
|
52
|
+
|
53
|
+
form
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
<%
|
58
|
+
|
59
|
+
if @event.id.nil?
|
60
|
+
|
61
|
+
resource_info = [@group, @event]
|
62
|
+
|
63
|
+
else
|
64
|
+
|
65
|
+
resource_info = [@event]
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
%>
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
<%= form_for( resource_info,:html => {:multipart => true, :class => "form-horizontal h-adr"}) do |f| %>
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
<div class="row ">
|
78
|
+
|
79
|
+
<div class="col-md-3" >
|
80
|
+
|
81
|
+
<div class="gray"><span class="label-title">タイトル</span></div>
|
82
|
+
|
83
|
+
</div>
|
84
|
+
|
85
|
+
<div class="col-md-9">
|
86
|
+
|
87
|
+
<%= f.text_field :title, :class =>"form-control" %>
|
88
|
+
|
89
|
+
</div>
|
90
|
+
|
91
|
+
</div>
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
<div class="row ">
|
96
|
+
|
97
|
+
<div class="col-md-3" >
|
98
|
+
|
99
|
+
<div class="gray"><span class="label-title">サブタイトル</span></div>
|
100
|
+
|
101
|
+
</div>
|
102
|
+
|
103
|
+
<div class="col-md-9">
|
104
|
+
|
105
|
+
<%= f.text_field :subtitle, :class =>"form-control" %>
|
106
|
+
|
107
|
+
</div>
|
108
|
+
|
109
|
+
</div>
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
<div class="row ">
|
114
|
+
|
115
|
+
<div class="col-md-3" >
|
116
|
+
|
117
|
+
<div class="gray"><span class="label-title">概要</span></div>
|
118
|
+
|
119
|
+
</div>
|
120
|
+
|
121
|
+
<div class="col-md-9">
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
<%= f.text_area :description, rows:15,:id => "event_description" ,:class =>"form-control" %>
|
128
|
+
|
129
|
+
</div>
|
130
|
+
|
131
|
+
</div>
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
<div class="row ">
|
136
|
+
|
137
|
+
<div class="col-md-3" >
|
138
|
+
|
139
|
+
<div class="gray"><span class="label-title">場所</span></div>
|
140
|
+
|
141
|
+
</div>
|
142
|
+
|
143
|
+
<div class="col-md-9" >
|
144
|
+
|
145
|
+
<div class="row">
|
146
|
+
|
147
|
+
<div class="col-md-3">
|
148
|
+
|
149
|
+
<%= f.label :zipcode,"郵便番号"%>
|
150
|
+
|
151
|
+
<%= f.text_field :zipcode ,:placeholder =>"郵便番号", :id => "event_zipcode", :class =>"form-control p-postal-code" %>
|
152
|
+
|
153
|
+
</div>
|
154
|
+
|
155
|
+
</div>
|
156
|
+
|
157
|
+
<%= f.label :address,"住所"%>
|
158
|
+
|
159
|
+
<div class="row">
|
160
|
+
|
161
|
+
<div class="col-md-3">
|
162
|
+
|
163
|
+
<%= f.text_field :pref ,:placeholder =>"都道府県 ", :class =>"form-control p-region" %>
|
164
|
+
|
165
|
+
</div>
|
166
|
+
|
167
|
+
<div class="col-md-3">
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
<%= f.text_field :city ,:placeholder =>"市区 ", :id => "address_city", :class =>"form-control p-locality" %>
|
172
|
+
|
173
|
+
</div>
|
174
|
+
|
175
|
+
<div class="col-md-6">
|
176
|
+
|
177
|
+
<%= f.text_field :address02,:placeholder =>"住所 ",:id => "address_street",:class =>"p-street-address p-extended-address form-control" %>
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
|
182
|
+
|
183
|
+
</div>
|
184
|
+
|
185
|
+
</div>
|
186
|
+
|
187
|
+
|
188
|
+
|
189
|
+
</div>
|
190
|
+
|
191
|
+
</div>
|
192
|
+
|
193
|
+
|
194
|
+
|
195
|
+
<div class="row ">
|
196
|
+
|
197
|
+
<div class="col-md-12">
|
198
|
+
|
199
|
+
|
200
|
+
|
201
|
+
<div id="tickets">
|
202
|
+
|
203
|
+
<%= f.fields_for :tickets do |builder| %>
|
204
|
+
|
205
|
+
<%= render "ticket_fields", f: builder %>
|
206
|
+
|
207
|
+
<% end %>
|
208
|
+
|
209
|
+
<div class="links text-center">
|
210
|
+
|
211
|
+
<%= link_to_add_association "追加",f, :tickets, :class => "btn btn-info btn-lg" %>
|
212
|
+
|
213
|
+
</div>
|
214
|
+
|
215
|
+
|
216
|
+
|
217
|
+
</div>
|
218
|
+
|
219
|
+
</div>
|
220
|
+
|
221
|
+
</div>
|
222
|
+
|
223
|
+
|
224
|
+
|
225
|
+
<div class="col-md-4 col-md-offset-4 mt20">
|
226
|
+
|
227
|
+
|
228
|
+
|
229
|
+
<%= f.submit "保存" ,:id =>"eventsubmit" ,:class => "btn btn-lg btn-success btn-block" ,:disabled => "disabled" %>
|
230
|
+
|
231
|
+
</div>
|
232
|
+
|
233
|
+
<% end %>
|
234
|
+
|
235
|
+
</div>
|
236
|
+
|
237
|
+
|
238
|
+
|
239
|
+
```
|
240
|
+
|
241
|
+
```ruby
|
46
242
|
|
47
243
|
ticket_fields.html.erb
|
48
244
|
|
245
|
+
cocoonのpartialの部分です。
|
246
|
+
|
247
|
+
|
248
|
+
|
249
|
+
<div class="nested-fields">
|
250
|
+
|
251
|
+
<h3>tickets</h3>
|
252
|
+
|
253
|
+
|
254
|
+
|
255
|
+
|
256
|
+
|
257
|
+
<div class="row text-center">
|
258
|
+
|
259
|
+
<div class="col-md-3">
|
260
|
+
|
261
|
+
<span class="label-title">title</span>
|
262
|
+
|
263
|
+
</div>
|
264
|
+
|
265
|
+
<div class="col-md-9">
|
266
|
+
|
267
|
+
<div class='input-group'>
|
268
|
+
|
269
|
+
<%= f.text_field :title, :class => "form-control" %
|
270
|
+
|
271
|
+
</div>
|
272
|
+
|
273
|
+
</div>
|
274
|
+
|
275
|
+
</div>
|
276
|
+
|
277
|
+
|
278
|
+
|
279
|
+
|
280
|
+
|
281
|
+
<div class="row text-center">
|
282
|
+
|
283
|
+
<div class="col-md-3">
|
284
|
+
|
285
|
+
<span class="label-title">対象者</span>
|
286
|
+
|
287
|
+
</div>
|
288
|
+
|
289
|
+
|
290
|
+
|
291
|
+
<div class="col-md-9">
|
292
|
+
|
293
|
+
<%= f.hidden_field :id %>
|
294
|
+
|
295
|
+
|
296
|
+
|
49
297
|
<% students = { '小学生' => 1, '中学生' => 2, '高校生' => 3 } %>
|
50
298
|
|
51
299
|
|
@@ -56,37 +304,27 @@
|
|
56
304
|
|
57
305
|
<%= f.label :student_type, st, :value => i %>
|
58
306
|
|
59
|
-
<% end %>
|
307
|
+
<% end %>
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
308
|
+
|
66
|
-
|
309
|
+
|
310
|
+
|
67
|
-
|
311
|
+
</div>
|
68
|
-
|
69
|
-
|
312
|
+
|
70
|
-
|
71
|
-
else
|
72
|
-
|
73
|
-
|
313
|
+
</div>
|
74
|
-
|
75
|
-
|
314
|
+
|
76
|
-
|
77
|
-
|
315
|
+
|
78
|
-
|
79
|
-
|
80
|
-
|
316
|
+
|
317
|
+
|
318
|
+
|
81
|
-
<%=
|
319
|
+
<%= link_to_remove_association 'remove this', f %>
|
82
|
-
|
83
|
-
|
84
|
-
|
320
|
+
|
85
|
-
|
321
|
+
</div>
|
86
|
-
|
87
|
-
|
88
|
-
|
322
|
+
|
89
|
-
```
|
323
|
+
```
|
324
|
+
|
325
|
+
|
326
|
+
|
327
|
+
|
90
328
|
|
91
329
|
上記のようなフォームから、下記のようにDBに格納されたことは確認できました。
|
92
330
|
|
@@ -136,10 +374,6 @@
|
|
136
374
|
|
137
375
|
|
138
376
|
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
377
|
###補足情報(言語/FW/ツール等のバージョンなど)
|
144
378
|
|
145
379
|
|
1
form_forの頭の部分を記載しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -59,6 +59,30 @@
|
|
59
59
|
<% end %>
|
60
60
|
|
61
61
|
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
<%
|
66
|
+
|
67
|
+
if @event.id.nil?
|
68
|
+
|
69
|
+
resource_info = [@group, @event]
|
70
|
+
|
71
|
+
else
|
72
|
+
|
73
|
+
resource_info = [@event]
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
%>
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
<%= form_for( resource_info,:html => {:multipart => true, :class => "form-horizontal h-adr"}) do |f| %>
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
eventはGroupの子供で、routesにshallowを使っていて、editとnewとで同様のformを使うために上記のような実装となっています。
|
62
86
|
|
63
87
|
|
64
88
|
|