質問編集履歴
4
コンソールからのレコード追加を試行
title
CHANGED
File without changes
|
body
CHANGED
@@ -199,7 +199,7 @@
|
|
199
199
|
$ bundle exec rails c
|
200
200
|
Loading development environment (Rails 5.2.4.4)
|
201
201
|
[1] pry(main)>
|
202
|
-
[2] pry(main)> Contact.create(name:"Taro", mail:"test@gmail.com", mail_confirmation: "test@gmail.com", message: "hello world")
|
202
|
+
[2] pry(main)> contact = Contact.create(name:"Taro", mail:"test@gmail.com", mail_confirmation: "test@gmail.com", message: "hello world")
|
203
203
|
(0.4ms) SET NAMES utf8, @@SESSION.sql_mode = CONCAT(CONCAT(@@sql_mode, ',STRICT_ALL_TABLES'), ',NO_AUTO_VALUE_ON_ZERO'), @@SESSION.sql_auto_is_null = 0, @@SESSION.wait_timeout = 2147483
|
204
204
|
(0.1ms) BEGIN
|
205
205
|
Contact Create (0.3ms) INSERT INTO `contacts` (`created_at`, `updated_at`) VALUES ('2021-01-28 09:20:20', '2021-01-28 09:20:20')
|
3
コンソールからのレコード追加を試行
title
CHANGED
File without changes
|
body
CHANGED
@@ -11,6 +11,8 @@
|
|
11
11
|
confirm → completeに移動する際、DBに空で入ってしまいます。
|
12
12
|

|
13
13
|
|
14
|
+
rails c でコンソールから直接書き込もうとしてもNilになってしまいます。
|
15
|
+
|
14
16
|
### 該当のソースコード
|
15
17
|
|
16
18
|
**/controller/contact_controller.rb**
|
@@ -192,6 +194,26 @@
|
|
192
194
|
Completed 200 OK in 85ms (Views: 57.0ms | ActiveRecord: 2.8ms)
|
193
195
|
```
|
194
196
|
|
197
|
+
**コンソールで直接追加を試行**
|
198
|
+
```rails c
|
199
|
+
$ bundle exec rails c
|
200
|
+
Loading development environment (Rails 5.2.4.4)
|
201
|
+
[1] pry(main)>
|
202
|
+
[2] pry(main)> Contact.create(name:"Taro", mail:"test@gmail.com", mail_confirmation: "test@gmail.com", message: "hello world")
|
203
|
+
(0.4ms) SET NAMES utf8, @@SESSION.sql_mode = CONCAT(CONCAT(@@sql_mode, ',STRICT_ALL_TABLES'), ',NO_AUTO_VALUE_ON_ZERO'), @@SESSION.sql_auto_is_null = 0, @@SESSION.wait_timeout = 2147483
|
204
|
+
(0.1ms) BEGIN
|
205
|
+
Contact Create (0.3ms) INSERT INTO `contacts` (`created_at`, `updated_at`) VALUES ('2021-01-28 09:20:20', '2021-01-28 09:20:20')
|
206
|
+
(0.6ms) COMMIT
|
207
|
+
=> #<Contact:0x00007fb75bc29f10
|
208
|
+
id: 24,
|
209
|
+
name: nil,
|
210
|
+
mail: nil,
|
211
|
+
mail_confirmation: nil,
|
212
|
+
message: nil,
|
213
|
+
created_at: Thu, 28 Jan 2021 18:20:20 JST +09:00,
|
214
|
+
updated_at: Thu, 28 Jan 2021 18:20:20 JST +09:00>
|
215
|
+
[3] pry(main)>
|
216
|
+
```
|
195
217
|
|
196
218
|
### 補足情報(FW/ツールのバージョンなど)
|
197
219
|
|
2
if contact.save! を試した場合を追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -106,7 +106,7 @@
|
|
106
106
|
|
107
107
|
### 試したこと
|
108
108
|
|
109
|
-
binding.pryを
|
109
|
+
**binding.pryを試した場合**
|
110
110
|
|
111
111
|
```terminal
|
112
112
|
17: def complete
|
@@ -128,6 +128,71 @@
|
|
128
128
|
[3] pry(#<ContactController>)>
|
129
129
|
```
|
130
130
|
|
131
|
+
**if contact.save! を試した場合**
|
132
|
+
```terminal
|
133
|
+
Started GET "/contact" for ::1 at 2021-01-27 17:51:17 +0900
|
134
|
+
Processing by ContactController#index as HTML
|
135
|
+
Rendering contact/index.html.haml within layouts/application
|
136
|
+
Rendered contact/index.html.haml within layouts/application (3.8ms)
|
137
|
+
Rendered layouts/_flash.html.haml (1.3ms)
|
138
|
+
Rendered layouts/_main_header.html.haml (6.7ms)
|
139
|
+
Rendered layouts/_session_controller.html.haml (2.2ms)
|
140
|
+
Rendered layouts/_main_footer.html.haml (5.7ms)
|
141
|
+
Completed 200 OK in 218ms (Views: 206.9ms | ActiveRecord: 1.9ms)
|
142
|
+
|
143
|
+
|
144
|
+
Started POST "/contact/confirm" for ::1 at 2021-01-27 17:51:33 +0900
|
145
|
+
Processing by ContactController#confirm as HTML
|
146
|
+
Parameters: {"utf8"=>"✓", "authenticity_token"=>"1udTs/YkCfBWq5tGcPve+X0FY6x4tCrzj/1R+XL8xdZxjtGmE30n0Mx0krayDKHWBeddQLc4AntxF0XivHsq8g==", "contact"=>{"name"=>"test", "mail"=>"test@sample.com", "mail_confirmation"=>"test@sample.com", "message"=>"sample"}, "commit"=>"確認"}
|
147
|
+
Rendering contact/confirm.html.haml within layouts/application
|
148
|
+
Rendered contact/confirm.html.haml within layouts/application (3.2ms)
|
149
|
+
Rendered layouts/_flash.html.haml (1.3ms)
|
150
|
+
Rendered layouts/_main_header.html.haml (3.3ms)
|
151
|
+
Rendered layouts/_session_controller.html.haml (1.5ms)
|
152
|
+
Rendered layouts/_main_footer.html.haml (3.6ms)
|
153
|
+
Completed 200 OK in 67ms (Views: 66.3ms | ActiveRecord: 0.0ms)
|
154
|
+
|
155
|
+
|
156
|
+
Started POST "/contact/complete" for ::1 at 2021-01-27 17:51:35 +0900
|
157
|
+
Processing by ContactController#complete as HTML
|
158
|
+
Parameters: {"utf8"=>"✓", "authenticity_token"=>"ACdr0CyeD2YCH6u8hwilPj6N6fXGWLyxL7rDl6vVnPinTunFycchRpjAokxF/9oRRm/XGQnUlDnRUNeMZVJz3A==", "contact"=>{"name"=>"test", "mail"=>"test@sample.com", "mail_confirmation"=>"test@sample.com", "message"=>"sample"}, "commit"=>"送信"}
|
159
|
+
Rendering contact_mailer/received_email.text.haml
|
160
|
+
Rendered contact_mailer/received_email.text.haml (1.1ms)
|
161
|
+
ContactMailer#received_email: processed outbound mail in 9.7ms
|
162
|
+
/usr/bin/open file:////Users/01018540/projects/reframe-lab/tmp/letter_opener/1611737495_265122_610c5dc/plain.html
|
163
|
+
Sent mail to test@sample.com (6.5ms)
|
164
|
+
Date: Wed, 27 Jan 2021 17:51:35 +0900
|
165
|
+
From: example@example.com
|
166
|
+
To: test@sample.com
|
167
|
+
Message-ID: <6011299740a42_16a923fcfe39839cc381d9@CA6383.local.mail>
|
168
|
+
Subject: =?UTF-8?Q?=E3=81=8A=E5=95=8F=E3=81=84=E5=90=88=E3=82=8F=E3=81=9B=E3=82=92=E6=89=BF=E3=82=8A=E3=81=BE=E3=81=97=E3=81=9F?=
|
169
|
+
Mime-Version: 1.0
|
170
|
+
Content-Type: text/plain;
|
171
|
+
charset=UTF-8
|
172
|
+
Content-Transfer-Encoding: base64
|
173
|
+
|
174
|
+
V2Vi44K144Kk44OI44GL44KJ44GK5ZWP44GE5ZCI44KP44Gb44GM44GC44KK
|
175
|
+
44G+44GX44Gf44CCDQrllY/jgYTlkIjjgo/jgZvnlLvpnaLjgaflhaXlipvj
|
176
|
+
gZXjgozjgZ/msI/lkI06IHRlc3QNCuWVj+OBhOWQiOOCj+OBm+eUu+mdouOB
|
177
|
+
p+WFpeWKm+OBleOCjOOBn+ODoeODvOODq+OCouODieODrOOCuTogdGVzdEBz
|
178
|
+
YW1wbGUuY29tDQrllY/jgYTlkIjjgo/jgZvlhoXlrrk6DQpzYW1wbGUNCg==
|
179
|
+
|
180
|
+
(0.2ms) BEGIN
|
181
|
+
↳ app/controllers/contact_controller.rb:23
|
182
|
+
Contact Create (0.6ms) INSERT INTO `contacts` (`created_at`, `updated_at`) VALUES ('2021-01-27 08:51:35', '2021-01-27 08:51:35')
|
183
|
+
↳ app/controllers/contact_controller.rb:23
|
184
|
+
(2.0ms) COMMIT
|
185
|
+
↳ app/controllers/contact_controller.rb:23
|
186
|
+
Rendering contact/complete.html.haml within layouts/application
|
187
|
+
Rendered contact/complete.html.haml within layouts/application (1.9ms)
|
188
|
+
Rendered layouts/_flash.html.haml (1.0ms)
|
189
|
+
Rendered layouts/_main_header.html.haml (2.8ms)
|
190
|
+
Rendered layouts/_session_controller.html.haml (1.4ms)
|
191
|
+
Rendered layouts/_main_footer.html.haml (4.1ms)
|
192
|
+
Completed 200 OK in 85ms (Views: 57.0ms | ActiveRecord: 2.8ms)
|
193
|
+
```
|
194
|
+
|
195
|
+
|
131
196
|
### 補足情報(FW/ツールのバージョンなど)
|
132
197
|
|
133
198
|
```versions
|
1
誤認を与える文の削除
title
CHANGED
File without changes
|
body
CHANGED
@@ -107,8 +107,6 @@
|
|
107
107
|
### 試したこと
|
108
108
|
|
109
109
|
binding.pryを用いてみたところ、下記のことがわかっております。
|
110
|
-
・confirm → completeに移動する際、@contactの情報がnilになっている。
|
111
|
-
・ストロングパラーメタで設定しているcontact_paramsには情報が入っている。
|
112
110
|
|
113
111
|
```terminal
|
114
112
|
17: def complete
|