質問編集履歴

1

コントローラークラス全体の実装

2021/03/22 08:08

投稿

rzz
rzz

スコア45

test CHANGED
File without changes
test CHANGED
@@ -74,13 +74,27 @@
74
74
 
75
75
 
76
76
 
77
+
78
+
79
+ class UsersController < ApplicationController
80
+
81
+
82
+
83
+ def new
84
+
85
+ @user = User.new
86
+
87
+ end
88
+
89
+
90
+
77
91
  def create
78
92
 
79
93
  user = User.new(user_params)
80
94
 
81
95
  if user.save
82
96
 
83
- session[:user_id] = user.id # 新規登録でステートフルな通信を行う為に、DBに保存されたidをsessionに保存する
97
+ session[:user_id] = user.id
84
98
 
85
99
  redirect_to users_path, notice: "Completed Sign up!"
86
100
 
@@ -88,13 +102,17 @@
88
102
 
89
103
  render :new
90
104
 
91
- flash.now[:alert] = "Failed Sign up... Please Retry"
105
+ flash.now[:alert] = "Failed Sign up... Please Retry!"
92
106
 
93
107
  end
94
108
 
95
109
  end
96
110
 
97
111
 
112
+
113
+ def show
114
+
115
+ end
98
116
 
99
117
 
100
118
 
@@ -104,9 +122,15 @@
104
122
 
105
123
  def user_params
106
124
 
125
+
126
+
107
- params.require(:user).permit(:email, :password, :password_confirmation)
127
+ params.permit(:email, :password, :password_confirmation)
108
128
 
109
129
  end
130
+
131
+
132
+
133
+ end
110
134
 
111
135
 
112
136