質問編集履歴
4
コントローラの内容を追記しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -42,444 +42,410 @@
|
|
42
42
|
|
43
43
|
|
44
44
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
45
|
+
```ここに言語を入力
|
46
|
+
|
47
|
+
edit.html.erb
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
<% @title = '口座アカウントの編集' %>
|
52
|
+
|
53
|
+
<h1><%= @title %></h1>
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
<div id="generic-form">
|
58
|
+
|
59
|
+
<%= form_for @bank_form, as: 'form', url: :confirm_customer_bank do |f| %>
|
60
|
+
|
61
|
+
<%= render 'form', f: f %>
|
62
|
+
|
63
|
+
<div class="buttons">
|
64
|
+
|
65
|
+
<%= f.submit '確認画面へ進む' %>
|
66
|
+
|
67
|
+
<%= link_to 'キャンセル', :customer_root %>
|
68
|
+
|
69
|
+
</div>
|
70
|
+
|
71
|
+
<% end %>
|
72
|
+
|
73
|
+
</div>
|
74
|
+
|
75
|
+
```
|
76
|
+
|
77
|
+
```ここに言語を入力
|
78
|
+
|
79
|
+
confirm.html.erb
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
<% @title = '口座アカウントの更新(確認)' %>
|
84
|
+
|
85
|
+
<h1><%= @title %></h1>
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
<div id="generic-form">
|
90
|
+
|
91
|
+
<%= form_for @bank_form, as: 'form', url: :customer_bank do |f| %>
|
92
|
+
|
93
|
+
<p>以下の内容で口座アカウントを更新します。よろしいですか?</p>
|
94
|
+
|
95
|
+
<%= render 'confirming_form', f: f %>
|
96
|
+
|
97
|
+
<div class="buttons">
|
98
|
+
|
99
|
+
<%= f.submit '更新' %>
|
100
|
+
|
101
|
+
<%= f.submit '訂正', name: 'correct' %>
|
102
|
+
|
103
|
+
</div>
|
104
|
+
|
105
|
+
<% end %>
|
106
|
+
|
107
|
+
</div>
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
```
|
112
|
+
|
113
|
+
```ここに言語を入力
|
114
|
+
|
115
|
+
_confirming_form.html.erb
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
<fieldset id="bank-fields">
|
120
|
+
|
121
|
+
<legend>口座アカウント更新内容</legend>
|
122
|
+
|
123
|
+
<%= render 'bank_fields', f: f, confirming: true %>
|
124
|
+
|
125
|
+
</fieldset>
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
```
|
130
|
+
|
131
|
+
```ここに言語を入力
|
132
|
+
|
133
|
+
_form.html.erb
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
<%= FormPresenter.new(f, self).notes %>
|
138
|
+
|
139
|
+
<fieldset id="Bank-fields">
|
140
|
+
|
141
|
+
<legend>口座情報(正確に入力してください。)</legend>
|
142
|
+
|
143
|
+
<%= render 'bank_fields', f: f, confirming: false %>
|
144
|
+
|
145
|
+
</fieldset>
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
```
|
150
|
+
|
151
|
+
```ここに言語を入力
|
152
|
+
|
153
|
+
confirming_bank_form_presenter.rb
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
class ConfirmingBankFormPresenter < ConfirmingFormPresenter
|
158
|
+
|
159
|
+
def bk_name_block(name, label_text, options = {})
|
160
|
+
|
161
|
+
markup(:div, class: 'input-block') do |m|
|
162
|
+
|
163
|
+
m << decorated_label(name, label_text, options)
|
164
|
+
|
165
|
+
m.div(object.send(name), class: 'field-value')
|
166
|
+
|
167
|
+
m << hidden_field(name, options)
|
168
|
+
|
169
|
+
end
|
170
|
+
|
171
|
+
end
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
def office_block(name, label_text, options = {})
|
176
|
+
|
177
|
+
markup(:div, class: 'input-block') do |m|
|
178
|
+
|
179
|
+
m << decorated_label(name, label_text, options)
|
180
|
+
|
181
|
+
m.div(object.send(name), class: 'field-value')
|
182
|
+
|
183
|
+
m << hidden_field(name, options)
|
184
|
+
|
185
|
+
end
|
186
|
+
|
187
|
+
end
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
def account_block(name, label_text, options = {})
|
192
|
+
|
193
|
+
markup(:div, class: 'input-block') do |m|
|
194
|
+
|
195
|
+
m << decorated_label(name, label_text, options)
|
196
|
+
|
197
|
+
m.div(object.send(name), class: 'field-value')
|
198
|
+
|
199
|
+
m << hidden_field(name, options)
|
200
|
+
|
201
|
+
end
|
202
|
+
|
203
|
+
end
|
204
|
+
|
205
|
+
|
206
|
+
|
207
|
+
def acc_name_block(name, label_text, options = {})
|
208
|
+
|
209
|
+
markup(:div, class: 'input-block') do |m|
|
210
|
+
|
211
|
+
m << decorated_label(name, label_text, options)
|
212
|
+
|
213
|
+
m.div(object.send(name), class: 'field-value')
|
214
|
+
|
215
|
+
m << hidden_field(name, options)
|
216
|
+
|
217
|
+
end
|
218
|
+
|
219
|
+
end
|
220
|
+
|
221
|
+
|
222
|
+
|
223
|
+
def acc_name_kana_block(name, label_text, options = {})
|
224
|
+
|
225
|
+
markup(:div, class: 'input-block') do |m|
|
226
|
+
|
227
|
+
m << decorated_label(name, label_text, options)
|
228
|
+
|
229
|
+
m.div(object.send(name), class: 'field-value')
|
230
|
+
|
231
|
+
m << hidden_field(name, options)
|
232
|
+
|
233
|
+
end
|
234
|
+
|
235
|
+
end
|
236
|
+
|
237
|
+
end
|
238
|
+
|
239
|
+
```
|
240
|
+
|
241
|
+
以上ですが、confirming_bank_form_presenter.rb の m.div(object.send(name), class: 'field-value') のコードで確認画面にデータが表示されているのですが、編集した内容ではなく初期データが表示されてしまいます。どう記述すれば「編集」画面の内容を表示できるのでしょうか?
|
242
|
+
|
243
|
+
どなたか教えてください。宜しくお願いします。
|
244
|
+
|
245
|
+
|
246
|
+
|
247
|
+
追記
|
248
|
+
|
249
|
+
```ここに言語を入力
|
250
|
+
|
251
|
+
bank_form.rb
|
252
|
+
|
253
|
+
|
254
|
+
|
255
|
+
class Customer::BankForm
|
256
|
+
|
257
|
+
include ActiveModel::Model
|
258
|
+
|
259
|
+
|
260
|
+
|
261
|
+
attr_accessor :bank
|
262
|
+
|
263
|
+
delegate :persisted?, :valid?, :save, to: :bank
|
264
|
+
|
265
|
+
|
266
|
+
|
267
|
+
def initialize(bank = nil)
|
268
|
+
|
269
|
+
@bank = bank
|
270
|
+
|
271
|
+
@bank ||= Bank.new
|
272
|
+
|
273
|
+
@customer.build_bank unless @bank
|
274
|
+
|
275
|
+
end
|
276
|
+
|
277
|
+
|
278
|
+
|
279
|
+
def assign_attributes(params = {})
|
280
|
+
|
281
|
+
@params = params
|
282
|
+
|
283
|
+
end
|
284
|
+
|
285
|
+
```
|
286
|
+
|
287
|
+
追記
|
288
|
+
|
289
|
+
```ここに言語を入力
|
290
|
+
|
291
|
+
_bank_fields.html.erb
|
292
|
+
|
293
|
+
|
294
|
+
|
295
|
+
<%= f.fields_for :bank, f.object.bank do |ff| %>
|
296
|
+
|
297
|
+
<%= markup do |m|
|
298
|
+
|
299
|
+
p = confirming ? ConfirmingBankFormPresenter.new(ff, self) : BankFormPresenter.new(ff, self)
|
300
|
+
|
301
|
+
p.with_options(required: true) do |q|
|
302
|
+
|
303
|
+
m << q.bk_name_block(:bk_name, '銀行名')
|
304
|
+
|
305
|
+
m << q.office_block(:office, '支店名')
|
306
|
+
|
307
|
+
m << q.account_block(:account, '口座番号')
|
308
|
+
|
309
|
+
m << q.acc_name_block(:acc_name, '口座名義')
|
310
|
+
|
311
|
+
m << q.acc_name_kana_block(:acc_name_kana, '口座名義(フリガナ)')
|
312
|
+
|
313
|
+
end
|
314
|
+
|
315
|
+
end %>
|
316
|
+
|
317
|
+
<% end %>
|
318
|
+
|
319
|
+
|
320
|
+
|
321
|
+
```
|
322
|
+
|
323
|
+
追記
|
324
|
+
|
325
|
+
```ここに言語を入力
|
326
|
+
|
327
|
+
edit.html.erbが表示されたときの出力
|
328
|
+
|
329
|
+
|
330
|
+
|
331
|
+
Started PATCH "/mypage/bank" for 10.0.2.2 at 2017-10-18 12:23:34 +0000
|
332
|
+
|
333
|
+
Processing by Customer::BanksController#update as HTML
|
334
|
+
|
335
|
+
Parameters: {"utf8"=>"✓", "authenticity_token"=>"1chV0w0pxy53uFHxymlrUDzu1aIlq
|
336
|
+
|
337
|
+
ZXWPIvFui2YXpqKCfbAUqls2Yob43UadjW4nw7tfWWIupT+5v/+BCNv4Q==", "form"=>{"bank"=>{
|
338
|
+
|
339
|
+
"bk_name"=>"xyz銀行", "office"=>"いろは支店", "account"=>"1234567", "acc_name"=>
|
340
|
+
|
341
|
+
"佐藤一郎", "acc_name_kana"=>"サトウイチロウ"}}, "correct"=>"訂正", "host"=>"exa mple.com"}
|
342
|
+
|
343
|
+
|
344
|
+
|
345
|
+
|
346
|
+
|
347
|
+
confirm.html.erbの表示されたときの出力
|
348
|
+
|
349
|
+
|
350
|
+
|
351
|
+
Started PATCH "/mypage/bank/confirm" for 10.0.2.2 at 2017-10-18 12:23:52 +0000
|
352
|
+
|
353
|
+
Processing by Customer::BanksController#confirm as HTML
|
354
|
+
|
355
|
+
Parameters: {"utf8"=>"✓", "authenticity_token"=>"hiE+QpQjqQQexMF03G2OxsTuf17oA
|
356
|
+
|
357
|
+
dwxcT8npHiH3HPZ4J1Ry6MC8+Nnc/AMctAuZw5Hgagg83OzUh3gUTztCA==", "form"=>{"bank"=>{
|
358
|
+
|
359
|
+
"bk_name"=>"xyz銀行fd", "office"=>"いろは支店", "account"=>"1234567", "acc_name"
|
360
|
+
|
361
|
+
=>"佐藤一郎", "acc_name_kana"=>"サトウイチロウ"}}, "commit"=>"確認画面へ進む", "
|
362
|
+
|
363
|
+
host"=>"example.com"}
|
364
|
+
|
365
|
+
|
366
|
+
|
367
|
+
```
|
368
|
+
|
369
|
+
bk_nameを編集した時の出力です。これを見る限りデータは送られてきているのかな?って思いますが表示は編集前の値です。
|
370
|
+
|
371
|
+
|
372
|
+
|
373
|
+
|
374
|
+
|
375
|
+
追記
|
376
|
+
|
377
|
+
```ここに言語を入力
|
378
|
+
|
379
|
+
def confirm
|
380
|
+
|
381
|
+
@bank_form = Customer::BankForm.new(Bank.find_by(customer_id: current_customer.id))
|
382
|
+
|
383
|
+
@bank_form.assign_attributes(params[:form][:bank][:bk_name])
|
384
|
+
|
385
|
+
@bank_form.assign_attributes(params[:form][:bank][:office])
|
386
|
+
|
387
|
+
@bank_form.assign_attributes(params[:form][:bank][:account])
|
388
|
+
|
389
|
+
@bank_form.assign_attributes(params[:form][:bank][:acc_name])
|
390
|
+
|
391
|
+
@bank_form.assign_attributes(params[:form][:bank][:acc_name_kana])
|
392
|
+
|
393
|
+
if @bank_form.valid?
|
394
|
+
|
395
|
+
render action: 'confirm'
|
396
|
+
|
397
|
+
else
|
398
|
+
|
399
|
+
flash.now.alert = '入力に誤りがあります。'
|
400
|
+
|
401
|
+
render action: 'edit'
|
402
|
+
|
403
|
+
end
|
404
|
+
|
405
|
+
end
|
406
|
+
|
407
|
+
|
408
|
+
|
409
|
+
def create
|
410
|
+
|
411
|
+
end
|
412
|
+
|
413
|
+
|
414
|
+
|
415
|
+
def update
|
50
416
|
|
51
417
|
@bank_form = Customer::BankForm.new(Bank.find_by(customer_id: current_customer.id))
|
52
418
|
|
419
|
+
@bank_form.assign_attributes(params[:form][:bank][:bk_name])
|
420
|
+
|
421
|
+
@bank_form.assign_attributes(params[:form][:bank][:office])
|
422
|
+
|
423
|
+
@bank_form.assign_attributes(params[:form][:bank][:account])
|
424
|
+
|
425
|
+
@bank_form.assign_attributes(params[:form][:bank][:acc_name])
|
426
|
+
|
427
|
+
@bank_form.assign_attributes(params[:form][:bank][:acc_name_kana])
|
428
|
+
|
429
|
+
if params[:commit]
|
430
|
+
|
431
|
+
if @bank_form.save
|
432
|
+
|
433
|
+
flash.notice = '口座アカウントを更新しました。'
|
434
|
+
|
435
|
+
redirect_to :customer_root
|
436
|
+
|
437
|
+
else
|
438
|
+
|
439
|
+
flash.now.alert = '入力に誤りがあります。'
|
440
|
+
|
441
|
+
render action: 'edit'
|
442
|
+
|
53
|
-
end
|
443
|
+
end
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
# PATCH
|
58
|
-
|
59
|
-
def confirm
|
60
|
-
|
61
|
-
@bank_form = Customer::BankForm.new(Bank.find_by(customer_id: current_customer.id))
|
62
|
-
|
63
|
-
@bank_form.assign_attributes(bank_params)
|
64
|
-
|
65
|
-
if @bank_form.valid?
|
66
|
-
|
67
|
-
render action: 'confirm'
|
68
444
|
|
69
445
|
else
|
70
446
|
|
71
|
-
flash.now.alert = '入力に誤りがあります。'
|
72
|
-
|
73
447
|
render action: 'edit'
|
74
448
|
|
75
449
|
end
|
76
450
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
def update
|
82
|
-
|
83
|
-
@bank_form = Customer::BankForm.new(Bank.find_by(customer_id: current_customer.id))
|
84
|
-
|
85
|
-
@bank_form.assign_attributes(bank_params)
|
86
|
-
|
87
|
-
if params[:commit]
|
88
|
-
|
89
|
-
if @bank_form.save
|
90
|
-
|
91
|
-
flash.notice = '口座アカウントを更新しました。'
|
92
|
-
|
93
|
-
redirect_to :customer_root
|
94
|
-
|
95
|
-
else
|
96
|
-
|
97
|
-
flash.now.alert = '入力に誤りがあります。'
|
98
|
-
|
99
|
-
render action: 'edit'
|
100
|
-
|
101
|
-
end
|
102
|
-
|
103
|
-
else
|
104
|
-
|
105
|
-
render action: 'edit'
|
106
|
-
|
107
|
-
end
|
108
|
-
|
109
|
-
end
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
```
|
114
|
-
|
115
|
-
```ここに言語を入力
|
116
|
-
|
117
|
-
edit.html.erb
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
<% @title = '口座アカウントの編集' %>
|
122
|
-
|
123
|
-
<h1><%= @title %></h1>
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
<div id="generic-form">
|
128
|
-
|
129
|
-
<%= form_for @bank_form, as: 'form', url: :confirm_customer_bank do |f| %>
|
130
|
-
|
131
|
-
<%= render 'form', f: f %>
|
132
|
-
|
133
|
-
<div class="buttons">
|
134
|
-
|
135
|
-
<%= f.submit '確認画面へ進む' %>
|
136
|
-
|
137
|
-
<%= link_to 'キャンセル', :customer_root %>
|
138
|
-
|
139
|
-
</div>
|
140
|
-
|
141
|
-
<% end %>
|
142
|
-
|
143
|
-
</div>
|
144
|
-
|
145
|
-
```
|
146
|
-
|
147
|
-
```ここに言語を入力
|
148
|
-
|
149
|
-
confirm.html.erb
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
<% @title = '口座アカウントの更新(確認)' %>
|
154
|
-
|
155
|
-
<h1><%= @title %></h1>
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
<div id="generic-form">
|
160
|
-
|
161
|
-
<%= form_for @bank_form, as: 'form', url: :customer_bank do |f| %>
|
162
|
-
|
163
|
-
<p>以下の内容で口座アカウントを更新します。よろしいですか?</p>
|
164
|
-
|
165
|
-
<%= render 'confirming_form', f: f %>
|
166
|
-
|
167
|
-
<div class="buttons">
|
168
|
-
|
169
|
-
<%= f.submit '更新' %>
|
170
|
-
|
171
|
-
<%= f.submit '訂正', name: 'correct' %>
|
172
|
-
|
173
|
-
</div>
|
174
|
-
|
175
|
-
<% end %>
|
176
|
-
|
177
|
-
</div>
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
```
|
182
|
-
|
183
|
-
```ここに言語を入力
|
184
|
-
|
185
|
-
_confirming_form.html.erb
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
<fieldset id="bank-fields">
|
190
|
-
|
191
|
-
<legend>口座アカウント更新内容</legend>
|
192
|
-
|
193
|
-
<%= render 'bank_fields', f: f, confirming: true %>
|
194
|
-
|
195
|
-
</fieldset>
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
```
|
200
|
-
|
201
|
-
```ここに言語を入力
|
202
|
-
|
203
|
-
_form.html.erb
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
<%= FormPresenter.new(f, self).notes %>
|
208
|
-
|
209
|
-
<fieldset id="Bank-fields">
|
210
|
-
|
211
|
-
<legend>口座情報(正確に入力してください。)</legend>
|
212
|
-
|
213
|
-
<%= render 'bank_fields', f: f, confirming: false %>
|
214
|
-
|
215
|
-
</fieldset>
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
```
|
220
|
-
|
221
|
-
```ここに言語を入力
|
222
|
-
|
223
|
-
confirming_bank_form_presenter.rb
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
class ConfirmingBankFormPresenter < ConfirmingFormPresenter
|
228
|
-
|
229
|
-
def bk_name_block(name, label_text, options = {})
|
230
|
-
|
231
|
-
markup(:div, class: 'input-block') do |m|
|
232
|
-
|
233
|
-
m << decorated_label(name, label_text, options)
|
234
|
-
|
235
|
-
m.div(object.send(name), class: 'field-value')
|
236
|
-
|
237
|
-
m << hidden_field(name, options)
|
238
|
-
|
239
|
-
end
|
240
|
-
|
241
|
-
end
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
def office_block(name, label_text, options = {})
|
246
|
-
|
247
|
-
markup(:div, class: 'input-block') do |m|
|
248
|
-
|
249
|
-
m << decorated_label(name, label_text, options)
|
250
|
-
|
251
|
-
m.div(object.send(name), class: 'field-value')
|
252
|
-
|
253
|
-
m << hidden_field(name, options)
|
254
|
-
|
255
|
-
end
|
256
|
-
|
257
|
-
end
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
def account_block(name, label_text, options = {})
|
262
|
-
|
263
|
-
markup(:div, class: 'input-block') do |m|
|
264
|
-
|
265
|
-
m << decorated_label(name, label_text, options)
|
266
|
-
|
267
|
-
m.div(object.send(name), class: 'field-value')
|
268
|
-
|
269
|
-
m << hidden_field(name, options)
|
270
|
-
|
271
|
-
end
|
272
|
-
|
273
|
-
end
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
def acc_name_block(name, label_text, options = {})
|
278
|
-
|
279
|
-
markup(:div, class: 'input-block') do |m|
|
280
|
-
|
281
|
-
m << decorated_label(name, label_text, options)
|
282
|
-
|
283
|
-
m.div(object.send(name), class: 'field-value')
|
284
|
-
|
285
|
-
m << hidden_field(name, options)
|
286
|
-
|
287
|
-
end
|
288
|
-
|
289
|
-
end
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
def acc_name_kana_block(name, label_text, options = {})
|
294
|
-
|
295
|
-
markup(:div, class: 'input-block') do |m|
|
296
|
-
|
297
|
-
m << decorated_label(name, label_text, options)
|
298
|
-
|
299
|
-
m.div(object.send(name), class: 'field-value')
|
300
|
-
|
301
|
-
m << hidden_field(name, options)
|
302
|
-
|
303
|
-
end
|
304
|
-
|
305
|
-
end
|
306
|
-
|
307
|
-
end
|
308
|
-
|
309
|
-
```
|
310
|
-
|
311
|
-
以上ですが、confirming_bank_form_presenter.rb の m.div(object.send(name), class: 'field-value') のコードで確認画面にデータが表示されているのですが、編集した内容ではなく初期データが表示されてしまいます。どう記述すれば「編集」画面の内容を表示できるのでしょうか?
|
312
|
-
|
313
|
-
どなたか教えてください。宜しくお願いします。
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
追記
|
318
|
-
|
319
|
-
```ここに言語を入力
|
320
|
-
|
321
|
-
bank_form.rb
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
class Customer::BankForm
|
326
|
-
|
327
|
-
include ActiveModel::Model
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
attr_accessor :bank
|
332
|
-
|
333
|
-
delegate :persisted?, :valid?, :save, to: :bank
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
def initialize(bank = nil)
|
338
|
-
|
339
|
-
@bank = bank
|
340
|
-
|
341
|
-
@bank ||= Bank.new
|
342
|
-
|
343
|
-
@customer.build_bank unless @bank
|
344
|
-
|
345
|
-
end
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
def assign_attributes(params = {})
|
350
|
-
|
351
|
-
@params = params
|
352
|
-
|
353
|
-
end
|
354
|
-
|
355
|
-
```
|
356
|
-
|
357
|
-
追記
|
358
|
-
|
359
|
-
```ここに言語を入力
|
360
|
-
|
361
|
-
_bank_fields.html.erb
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
<%= f.fields_for :bank, f.object.bank do |ff| %>
|
366
|
-
|
367
|
-
<%= markup do |m|
|
368
|
-
|
369
|
-
p = confirming ? ConfirmingBankFormPresenter.new(ff, self) : BankFormPresenter.new(ff, self)
|
370
|
-
|
371
|
-
p.with_options(required: true) do |q|
|
372
|
-
|
373
|
-
m << q.bk_name_block(:bk_name, '銀行名')
|
374
|
-
|
375
|
-
m << q.office_block(:office, '支店名')
|
376
|
-
|
377
|
-
m << q.account_block(:account, '口座番号')
|
378
|
-
|
379
|
-
m << q.acc_name_block(:acc_name, '口座名義')
|
380
|
-
|
381
|
-
m << q.acc_name_kana_block(:acc_name_kana, '口座名義(フリガナ)')
|
382
|
-
|
383
|
-
end
|
384
|
-
|
385
|
-
end %>
|
386
|
-
|
387
|
-
<% end %>
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
```
|
392
|
-
|
393
|
-
追記
|
394
|
-
|
395
|
-
```ここに言語を入力
|
396
|
-
|
397
|
-
edit.html.erbが表示されたときの出力
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
Started PATCH "/mypage/bank" for 10.0.2.2 at 2017-10-18 12:23:34 +0000
|
402
|
-
|
403
|
-
Processing by Customer::BanksController#update as HTML
|
404
|
-
|
405
|
-
Parameters: {"utf8"=>"✓", "authenticity_token"=>"1chV0w0pxy53uFHxymlrUDzu1aIlq
|
406
|
-
|
407
|
-
ZXWPIvFui2YXpqKCfbAUqls2Yob43UadjW4nw7tfWWIupT+5v/+BCNv4Q==", "form"=>{"bank"=>{
|
408
|
-
|
409
|
-
"bk_name"=>"xyz銀行", "office"=>"いろは支店", "account"=>"1234567", "acc_name"=>
|
410
|
-
|
411
|
-
"佐藤一郎", "acc_name_kana"=>"サトウイチロウ"}}, "correct"=>"訂正", "host"=>"exa mple.com"}
|
412
|
-
|
413
|
-
Customer Load (0.5ms) SELECT `customers`.* FROM `customers` WHERE `customers
|
414
|
-
|
415
|
-
`.`id` = 1 LIMIT 1
|
416
|
-
|
417
|
-
Bank Load (1.3ms) SELECT `banks`.* FROM `banks` WHERE `banks`.`customer_id`
|
418
|
-
|
419
|
-
= 1 LIMIT 1
|
420
|
-
|
421
|
-
Rendering customer/banks/edit.html.erb within layouts/customer
|
422
|
-
|
423
|
-
Rendered customer/banks/_bank_fields.html.erb (14.1ms)
|
424
|
-
|
425
|
-
Rendered customer/banks/_form.html.erb (16.0ms)
|
426
|
-
|
427
|
-
Rendered customer/banks/edit.html.erb within layouts/customer (18.3ms)
|
428
|
-
|
429
|
-
Rendered customer/shared/_header.html.erb (1.1ms)
|
430
|
-
|
431
|
-
Rendered shared/_footer.html.erb (0.3ms)
|
432
|
-
|
433
|
-
Completed 200 OK in 327ms (Views: 321.2ms | ActiveRecord: 1.8ms)
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
confirm.html.erbの表示されたときの出力
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
Started PATCH "/mypage/bank/confirm" for 10.0.2.2 at 2017-10-18 12:23:52 +0000
|
446
|
-
|
447
|
-
Processing by Customer::BanksController#confirm as HTML
|
448
|
-
|
449
|
-
Parameters: {"utf8"=>"✓", "authenticity_token"=>"hiE+QpQjqQQexMF03G2OxsTuf17oA
|
450
|
-
|
451
|
-
dwxcT8npHiH3HPZ4J1Ry6MC8+Nnc/AMctAuZw5Hgagg83OzUh3gUTztCA==", "form"=>{"bank"=>{
|
452
|
-
|
453
|
-
"bk_name"=>"xyz銀行fd", "office"=>"いろは支店", "account"=>"1234567", "acc_name"
|
454
|
-
|
455
|
-
=>"佐藤一郎", "acc_name_kana"=>"サトウイチロウ"}}, "commit"=>"確認画面へ進む", "
|
456
|
-
|
457
|
-
host"=>"example.com"}
|
458
|
-
|
459
|
-
Customer Load (0.5ms) SELECT `customers`.* FROM `customers` WHERE `customers
|
460
|
-
|
461
|
-
`.`id` = 1 LIMIT 1
|
462
|
-
|
463
|
-
Bank Load (1.1ms) SELECT `banks`.* FROM `banks` WHERE `banks`.`customer_id`
|
464
|
-
|
465
|
-
= 1 LIMIT 1
|
466
|
-
|
467
|
-
Rendering customer/banks/confirm.html.erb within layouts/customer
|
468
|
-
|
469
|
-
Rendered customer/banks/_bank_fields.html.erb (13.0ms)
|
470
|
-
|
471
|
-
Rendered customer/banks/_confirming_form.html.erb (14.5ms)
|
472
|
-
|
473
|
-
Rendered customer/banks/confirm.html.erb within layouts/customer (16.4ms)
|
474
|
-
|
475
|
-
Rendered customer/shared/_header.html.erb (0.9ms)
|
476
|
-
|
477
|
-
Rendered shared/_footer.html.erb (0.0ms)
|
478
|
-
|
479
|
-
Completed 200 OK in 312ms (Views: 305.7ms | ActiveRecord: 1.5ms)
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
```
|
484
|
-
|
485
|
-
bk_nameを編集した時の出力です。これを見る限りデータは送られてきているのかな?って思いますが表示は編集前の値です。
|
451
|
+
```
|
3
コンソールの内容を追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -389,3 +389,97 @@
|
|
389
389
|
|
390
390
|
|
391
391
|
```
|
392
|
+
|
393
|
+
追記
|
394
|
+
|
395
|
+
```ここに言語を入力
|
396
|
+
|
397
|
+
edit.html.erbが表示されたときの出力
|
398
|
+
|
399
|
+
|
400
|
+
|
401
|
+
Started PATCH "/mypage/bank" for 10.0.2.2 at 2017-10-18 12:23:34 +0000
|
402
|
+
|
403
|
+
Processing by Customer::BanksController#update as HTML
|
404
|
+
|
405
|
+
Parameters: {"utf8"=>"✓", "authenticity_token"=>"1chV0w0pxy53uFHxymlrUDzu1aIlq
|
406
|
+
|
407
|
+
ZXWPIvFui2YXpqKCfbAUqls2Yob43UadjW4nw7tfWWIupT+5v/+BCNv4Q==", "form"=>{"bank"=>{
|
408
|
+
|
409
|
+
"bk_name"=>"xyz銀行", "office"=>"いろは支店", "account"=>"1234567", "acc_name"=>
|
410
|
+
|
411
|
+
"佐藤一郎", "acc_name_kana"=>"サトウイチロウ"}}, "correct"=>"訂正", "host"=>"exa mple.com"}
|
412
|
+
|
413
|
+
Customer Load (0.5ms) SELECT `customers`.* FROM `customers` WHERE `customers
|
414
|
+
|
415
|
+
`.`id` = 1 LIMIT 1
|
416
|
+
|
417
|
+
Bank Load (1.3ms) SELECT `banks`.* FROM `banks` WHERE `banks`.`customer_id`
|
418
|
+
|
419
|
+
= 1 LIMIT 1
|
420
|
+
|
421
|
+
Rendering customer/banks/edit.html.erb within layouts/customer
|
422
|
+
|
423
|
+
Rendered customer/banks/_bank_fields.html.erb (14.1ms)
|
424
|
+
|
425
|
+
Rendered customer/banks/_form.html.erb (16.0ms)
|
426
|
+
|
427
|
+
Rendered customer/banks/edit.html.erb within layouts/customer (18.3ms)
|
428
|
+
|
429
|
+
Rendered customer/shared/_header.html.erb (1.1ms)
|
430
|
+
|
431
|
+
Rendered shared/_footer.html.erb (0.3ms)
|
432
|
+
|
433
|
+
Completed 200 OK in 327ms (Views: 321.2ms | ActiveRecord: 1.8ms)
|
434
|
+
|
435
|
+
|
436
|
+
|
437
|
+
|
438
|
+
|
439
|
+
|
440
|
+
|
441
|
+
confirm.html.erbの表示されたときの出力
|
442
|
+
|
443
|
+
|
444
|
+
|
445
|
+
Started PATCH "/mypage/bank/confirm" for 10.0.2.2 at 2017-10-18 12:23:52 +0000
|
446
|
+
|
447
|
+
Processing by Customer::BanksController#confirm as HTML
|
448
|
+
|
449
|
+
Parameters: {"utf8"=>"✓", "authenticity_token"=>"hiE+QpQjqQQexMF03G2OxsTuf17oA
|
450
|
+
|
451
|
+
dwxcT8npHiH3HPZ4J1Ry6MC8+Nnc/AMctAuZw5Hgagg83OzUh3gUTztCA==", "form"=>{"bank"=>{
|
452
|
+
|
453
|
+
"bk_name"=>"xyz銀行fd", "office"=>"いろは支店", "account"=>"1234567", "acc_name"
|
454
|
+
|
455
|
+
=>"佐藤一郎", "acc_name_kana"=>"サトウイチロウ"}}, "commit"=>"確認画面へ進む", "
|
456
|
+
|
457
|
+
host"=>"example.com"}
|
458
|
+
|
459
|
+
Customer Load (0.5ms) SELECT `customers`.* FROM `customers` WHERE `customers
|
460
|
+
|
461
|
+
`.`id` = 1 LIMIT 1
|
462
|
+
|
463
|
+
Bank Load (1.1ms) SELECT `banks`.* FROM `banks` WHERE `banks`.`customer_id`
|
464
|
+
|
465
|
+
= 1 LIMIT 1
|
466
|
+
|
467
|
+
Rendering customer/banks/confirm.html.erb within layouts/customer
|
468
|
+
|
469
|
+
Rendered customer/banks/_bank_fields.html.erb (13.0ms)
|
470
|
+
|
471
|
+
Rendered customer/banks/_confirming_form.html.erb (14.5ms)
|
472
|
+
|
473
|
+
Rendered customer/banks/confirm.html.erb within layouts/customer (16.4ms)
|
474
|
+
|
475
|
+
Rendered customer/shared/_header.html.erb (0.9ms)
|
476
|
+
|
477
|
+
Rendered shared/_footer.html.erb (0.0ms)
|
478
|
+
|
479
|
+
Completed 200 OK in 312ms (Views: 305.7ms | ActiveRecord: 1.5ms)
|
480
|
+
|
481
|
+
|
482
|
+
|
483
|
+
```
|
484
|
+
|
485
|
+
bk_nameを編集した時の出力です。これを見る限りデータは送られてきているのかな?って思いますが表示は編集前の値です。
|
2
_bank_fields.html.erbを追記しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -353,3 +353,39 @@
|
|
353
353
|
end
|
354
354
|
|
355
355
|
```
|
356
|
+
|
357
|
+
追記
|
358
|
+
|
359
|
+
```ここに言語を入力
|
360
|
+
|
361
|
+
_bank_fields.html.erb
|
362
|
+
|
363
|
+
|
364
|
+
|
365
|
+
<%= f.fields_for :bank, f.object.bank do |ff| %>
|
366
|
+
|
367
|
+
<%= markup do |m|
|
368
|
+
|
369
|
+
p = confirming ? ConfirmingBankFormPresenter.new(ff, self) : BankFormPresenter.new(ff, self)
|
370
|
+
|
371
|
+
p.with_options(required: true) do |q|
|
372
|
+
|
373
|
+
m << q.bk_name_block(:bk_name, '銀行名')
|
374
|
+
|
375
|
+
m << q.office_block(:office, '支店名')
|
376
|
+
|
377
|
+
m << q.account_block(:account, '口座番号')
|
378
|
+
|
379
|
+
m << q.acc_name_block(:acc_name, '口座名義')
|
380
|
+
|
381
|
+
m << q.acc_name_kana_block(:acc_name_kana, '口座名義(フリガナ)')
|
382
|
+
|
383
|
+
end
|
384
|
+
|
385
|
+
end %>
|
386
|
+
|
387
|
+
<% end %>
|
388
|
+
|
389
|
+
|
390
|
+
|
391
|
+
```
|
1
コードの記述忘れがありました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -311,3 +311,45 @@
|
|
311
311
|
以上ですが、confirming_bank_form_presenter.rb の m.div(object.send(name), class: 'field-value') のコードで確認画面にデータが表示されているのですが、編集した内容ではなく初期データが表示されてしまいます。どう記述すれば「編集」画面の内容を表示できるのでしょうか?
|
312
312
|
|
313
313
|
どなたか教えてください。宜しくお願いします。
|
314
|
+
|
315
|
+
|
316
|
+
|
317
|
+
追記
|
318
|
+
|
319
|
+
```ここに言語を入力
|
320
|
+
|
321
|
+
bank_form.rb
|
322
|
+
|
323
|
+
|
324
|
+
|
325
|
+
class Customer::BankForm
|
326
|
+
|
327
|
+
include ActiveModel::Model
|
328
|
+
|
329
|
+
|
330
|
+
|
331
|
+
attr_accessor :bank
|
332
|
+
|
333
|
+
delegate :persisted?, :valid?, :save, to: :bank
|
334
|
+
|
335
|
+
|
336
|
+
|
337
|
+
def initialize(bank = nil)
|
338
|
+
|
339
|
+
@bank = bank
|
340
|
+
|
341
|
+
@bank ||= Bank.new
|
342
|
+
|
343
|
+
@customer.build_bank unless @bank
|
344
|
+
|
345
|
+
end
|
346
|
+
|
347
|
+
|
348
|
+
|
349
|
+
def assign_attributes(params = {})
|
350
|
+
|
351
|
+
@params = params
|
352
|
+
|
353
|
+
end
|
354
|
+
|
355
|
+
```
|