質問編集履歴

3

追記しました.

2022/10/17 13:12

投稿

sasaharukimedes
sasaharukimedes

スコア27

test CHANGED
File without changes
test CHANGED
@@ -90,6 +90,17 @@
90
90
  User Create (0.5ms) INSERT INTO "users" ("email", "encrypted_password", "reset_password_token", "reset_password_sent_at", "remember_created_at", "sign_in_count", "current_sign_in_at", "last_sign_in_at", "current_sign_in_ip", "last_sign_in_ip", "confirmation_token", "confirmed_at", "confirmation_sent_at", "unconfirmed_email", "failed_attempts", "unlock_token", "locked_at", "created_at", "updated_at", "name", "birthday", "received_at") VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22) RETURNING "id" [["email", "xxxxx.com"], ["encrypted_password", "[FILTERED]"], ["reset_password_token", "[FILTERED]"], ["reset_password_sent_at", "[FILTERED]"], ["remember_created_at", nil], ["sign_in_count", 0], ["current_sign_in_at", nil], ["last_sign_in_at", nil], ["current_sign_in_ip", nil], ["last_sign_in_ip", nil], ["confirmation_token", "[FILTERED]"], ["confirmed_at", nil], ["confirmation_sent_at", "2022-10-17 21:24:41.804202"], ["unconfirmed_email", nil], ["failed_attempts", 0], ["unlock_token", "[FILTERED]"], ["locked_at", nil], ["created_at", "2022-10-17 21:24:41.804083"], ["updated_at", "2022-10-17 21:24:41.804083"], ["name", "xxxxxx"], ["birthday", "2022-09-25"], ["received_at", nil]]
91
91
  ```
92
92
 
93
+ ```ApplicationController.rb
94
+ before_action :configure_permitted_parameters, if: :devise_controller?
95
+
96
+ protected
97
+ def configure_permitted_parameters
98
+ added_attrs = [ :email, :name, :birthday, :password, :password_confirmation, :received_at]
99
+ devise_parameter_sanitizer.permit :sign_up, keys: added_attrs
100
+ devise_parameter_sanitizer.permit :account_update, keys: added_attrs
101
+ devise_parameter_sanitizer.permit :sign_in, keys: added_attrs
102
+ end
103
+ ```
93
104
 
94
105
 
95
106
 

2

追記を作成しました.ログです.

2022/10/17 12:46

投稿

sasaharukimedes
sasaharukimedes

スコア27

test CHANGED
File without changes
test CHANGED
@@ -12,13 +12,7 @@
12
12
 
13
13
  つまり、以下でメールなりなんなりが入った段階で問題のreceived _atにも入っててほしいわけなのに、入ってないのです。
14
14
 
15
-
16
- ```コマンドプロンプトの出力結果
17
- 一部略
18
- [["email", "xxxxx.com"],
15
+ →以下というのは追記に移行しました.Rails S した部分のログです.
19
- ["encrypted_password", "[FILTERED]"],
20
- ["created_at", "2022-10-16 21:32:18.541640"], ["updated_at", "2022-10-16 21:32:18.541640"], ["name", "xxxx"], ["birthday", "2022-09-25"], ["received_at", nil]]
21
- ```
22
16
 
23
17
  このreceived_atがUser作成時点でcreated_atらと同様に入っていてほしいです.
24
18
 
@@ -33,7 +27,7 @@
33
27
  end
34
28
 
35
29
  def initialize
36
- @user.received_at = params[received_at: :Time.current]
30
+ @user.received_at = params[received_at: :Time.now]
37
31
  end
38
32
 
39
33
  def create
@@ -47,6 +41,13 @@
47
41
  render 'new'
48
42
  end
49
43
  end
44
+
45
+ private
46
+ def user_params
47
+ params.require(:user).permit(:name, :email, :birthday, :received_at)
48
+ end
49
+
50
+
50
51
  ```
51
52
 
52
53
 
@@ -75,3 +76,23 @@
75
76
  Rails 7.0.4
76
77
  Devise Gem でユーザー登録実装
77
78
 
79
+ ### 追記
80
+
81
+ rails s して試しに新規登録してみるとこんな感じで出ます.
82
+ どうしてreceived_atが入らないのか...
83
+
84
+ ```ここに言語を入力
85
+ Started POST "/users" for ::1 at 2022-10-17 21:24:41 +0900
86
+ Processing by Devise::RegistrationsController#create as HTML
87
+ Parameters: {"authenticity_token"=>"[FILTERED]", "user"=>{"name"=>"xxxx", "birthday"=>"2022-09-25", "email"=>"xxxxx.com", "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]"}, "commit"=>"アカウント登録"}
88
+ TRANSACTION (0.1ms) BEGIN
89
+ User Exists? (0.6ms) SELECT 1 AS one FROM "users" WHERE "users"."email" = $1 LIMIT $2 [["email", "xxxxxx.com"], ["LIMIT", 1]]
90
+ User Create (0.5ms) INSERT INTO "users" ("email", "encrypted_password", "reset_password_token", "reset_password_sent_at", "remember_created_at", "sign_in_count", "current_sign_in_at", "last_sign_in_at", "current_sign_in_ip", "last_sign_in_ip", "confirmation_token", "confirmed_at", "confirmation_sent_at", "unconfirmed_email", "failed_attempts", "unlock_token", "locked_at", "created_at", "updated_at", "name", "birthday", "received_at") VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22) RETURNING "id" [["email", "xxxxx.com"], ["encrypted_password", "[FILTERED]"], ["reset_password_token", "[FILTERED]"], ["reset_password_sent_at", "[FILTERED]"], ["remember_created_at", nil], ["sign_in_count", 0], ["current_sign_in_at", nil], ["last_sign_in_at", nil], ["current_sign_in_ip", nil], ["last_sign_in_ip", nil], ["confirmation_token", "[FILTERED]"], ["confirmed_at", nil], ["confirmation_sent_at", "2022-10-17 21:24:41.804202"], ["unconfirmed_email", nil], ["failed_attempts", 0], ["unlock_token", "[FILTERED]"], ["locked_at", nil], ["created_at", "2022-10-17 21:24:41.804083"], ["updated_at", "2022-10-17 21:24:41.804083"], ["name", "xxxxxx"], ["birthday", "2022-09-25"], ["received_at", nil]]
91
+ ```
92
+
93
+
94
+
95
+
96
+
97
+
98
+

1

追記しました。

2022/10/17 00:18

投稿

sasaharukimedes
sasaharukimedes

スコア27

test CHANGED
File without changes
test CHANGED
@@ -8,9 +8,17 @@
8
8
 
9
9
  ### 発生している問題・エラーメッセージ
10
10
 
11
+ 以下は、Rails sして実際にローカルで立ち上げた後にユーザー登録画面から登録しようとした際に、コマンドプロンプトに出力されたものです。フォームに名前、メアド、パスワード、誕生日を入れてもらい、それと別でコントローラ内のコードでreceived _atという今回問題の値を入れるという流れです。
12
+
13
+ つまり、以下でメールなりなんなりが入った段階で問題のreceived _atにも入っててほしいわけなのに、入ってないのです。
14
+
15
+
16
+ ```コマンドプロンプトの出力結果
17
+ 一部略
11
18
  [["email", "xxxxx.com"],
12
19
  ["encrypted_password", "[FILTERED]"],
13
20
  ["created_at", "2022-10-16 21:32:18.541640"], ["updated_at", "2022-10-16 21:32:18.541640"], ["name", "xxxx"], ["birthday", "2022-09-25"], ["received_at", nil]]
21
+ ```
14
22
 
15
23
  このreceived_atがUser作成時点でcreated_atらと同様に入っていてほしいです.
16
24