質問編集履歴

3

2019/08/23 02:49

投稿

k_yusuke
k_yusuke

スコア19

test CHANGED
File without changes
test CHANGED
@@ -46,7 +46,7 @@
46
46
 
47
47
  ### 該当のソースコード
48
48
 
49
- app/controssler/users_controller.rb(追記ました)
49
+ app/controssler/users_controller.rb(省略な・全文)
50
50
 
51
51
  ```ここに言語名を入力
52
52
 
@@ -58,6 +58,42 @@
58
58
 
59
59
  before_action :check_user_login?, only: [:show]
60
60
 
61
+
62
+
63
+
64
+
65
+ def new
66
+
67
+ @user=User.new
68
+
69
+ end
70
+
71
+
72
+
73
+
74
+
75
+ def create
76
+
77
+ @user=User.new(user_params)
78
+
79
+ if @user.save
80
+
81
+ current_user = @user
82
+
83
+ redirect_to root_path
84
+
85
+ else
86
+
87
+ #パラムスを持つユーザー
88
+
89
+ render new_user_path
90
+
91
+ end
92
+
93
+ end
94
+
95
+
96
+
61
97
 
62
98
 
63
99
  def edit
@@ -72,17 +108,75 @@
72
108
 
73
109
  def update
74
110
 
75
- 30 user_find_by_id
111
+ user_find_by_id
112
+
76
-
113
+ binding.pry
114
+
77
- 31 if @user.update(user_params)
115
+ if @user.update(user_params)
78
-
116
+
79
- 32 redirect_to user_path(id: current_user.id)
117
+ redirect_to user_path(id: current_user.id)
80
-
118
+
81
- else
119
+ else
82
-
120
+
83
- render edit_user_path
121
+ render edit_user_path
84
-
122
+
85
- end
123
+ end
124
+
125
+ end
126
+
127
+
128
+
129
+
130
+
131
+ def destroy
132
+
133
+ user_find_by_id
134
+
135
+ @user.destroy
136
+
137
+ end
138
+
139
+
140
+
141
+ def show
142
+
143
+ user_find_by_id
144
+
145
+ @tours = Tour.where(user_id: @user.id)
146
+
147
+ end
148
+
149
+
150
+
151
+ def followings
152
+
153
+ user_find_by_id
154
+
155
+ @users = @user.followings.page(params[:page])
156
+
157
+ render 'follow'
158
+
159
+ end
160
+
161
+
162
+
163
+ def followers
164
+
165
+ user_find_by_id
166
+
167
+ @users = @user.followers.page(params[:page])
168
+
169
+ render 'follow'
170
+
171
+ end
172
+
173
+
174
+
175
+ def favorite
176
+
177
+ @tours = current_user.favtours.page(params[:page])
178
+
179
+ end
86
180
 
87
181
 
88
182
 
@@ -226,4 +320,46 @@
226
320
 
227
321
  ```
228
322
 
323
+ ###追記(binding.pryを使った行の可視化、上記のusers_controller.rbにも追記あり)
324
+
325
+ ```ここに言語を入力
326
+
327
+ From: /home/ec2-user/environment/new_app2/app/controllers/users_controller.rb @ line 32 User
328
+
329
+ sController#update:
330
+
331
+
332
+
333
+ 29: def update
334
+
335
+ 30: user_find_by_id
336
+
337
+ 31: binding.pry#(実際にはこの行は挿入されていないので、↓のif行が31行目になります)
338
+
339
+ => 32: if @user.update(user_params)
340
+
341
+ 33: redirect_to user_path(id: current_user.id)
342
+
343
+ 34: else
344
+
345
+ :
346
+
347
+
348
+
349
+ この場合のエラーメッセージは
350
+
351
+
352
+
353
+
354
+
355
+ ArgumentError (wrong number of arguments (given 0, expected 1)):
356
+
357
+
358
+
229
- app/controssler/users_controller.rbに追記しました
359
+ app/controllers/users_controller.rb:32:in `update'
360
+
361
+
362
+
363
+ でした
364
+
365
+ ```

2

2019/08/23 02:49

投稿

k_yusuke
k_yusuke

スコア19

test CHANGED
File without changes
test CHANGED
@@ -46,7 +46,7 @@
46
46
 
47
47
  ### 該当のソースコード
48
48
 
49
- app/controssler/users_controller.rb
49
+ app/controssler/users_controller.rb(追記しました)
50
50
 
51
51
  ```ここに言語名を入力
52
52
 
@@ -225,3 +225,5 @@
225
225
 
226
226
 
227
227
  ```
228
+
229
+ app/controssler/users_controller.rbに追記しました

1

31

2019/08/23 02:13

投稿

k_yusuke
k_yusuke

スコア19

test CHANGED
File without changes
test CHANGED
@@ -72,17 +72,17 @@
72
72
 
73
73
  def update
74
74
 
75
- user_find_by_id
75
+ 30 user_find_by_id
76
-
76
+
77
- if @user.update(user_params)
77
+ 31 if @user.update(user_params)
78
-
78
+
79
- redirect_to user_path(id: current_user.id)
79
+ 32 redirect_to user_path(id: current_user.id)
80
-
80
+
81
- else
81
+ else
82
-
82
+
83
- render edit_user_path
83
+ render edit_user_path
84
-
84
+
85
- end
85
+ end
86
86
 
87
87
 
88
88