質問編集履歴
1
コードの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -21,3 +21,71 @@
|
|
21
21
|
|
22
22
|
|
23
23
|
そのrender後のURLをusers/newに変えるには、リダイレクト以外何か方法があるのでしょうか?
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
コードは正確には↓のような感じです。
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
```
|
34
|
+
|
35
|
+
class UsersController < ApplicationController
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
def new
|
40
|
+
|
41
|
+
@user = User.new
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
def show
|
48
|
+
|
49
|
+
@user = User.find(params[:id])
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
def create
|
56
|
+
|
57
|
+
@user = User.new(user_params)
|
58
|
+
|
59
|
+
if @user.save
|
60
|
+
|
61
|
+
redirect_to user_path(@user)
|
62
|
+
|
63
|
+
else
|
64
|
+
|
65
|
+
render :new
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
```
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
```
|
78
|
+
|
79
|
+
Rails.application.routes.draw do
|
80
|
+
|
81
|
+
root "sessions#new"
|
82
|
+
|
83
|
+
resources :sessions, only: %i(new create destroy)
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
resources :users, only: %i(new create show)
|
88
|
+
|
89
|
+
end
|
90
|
+
|
91
|
+
```
|