質問編集履歴

1

<code>に変更

2020/02/11 13:14

投稿

H.T.
H.T.

スコア5

test CHANGED
File without changes
test CHANGED
@@ -6,20 +6,246 @@
6
6
 
7
7
 
8
8
 
9
- ![![![イメージ](d993908dbc0e51909b8ef841ba4c819e.png)](8f7b6b8d7d7d6e15c7ba267ec597d1ce.png)
10
-
11
-
12
-
13
- ![イメージ説明](28a53ae4e6b03dffebb09a12d446cb41.png)
14
-
15
-
16
-
17
- ![イメージ説明](72654ae64f17439b63c768c0bd1e9461.png)
18
-
19
-
20
-
21
- ![イメージ説明](ac93c95ec6dec3f8b0e899785bac9b0c.png)
22
-
23
-
24
-
25
- ![イメージ説明](9f7f5f60c314bc1a2bf8b5bc3b301d0d.png)
9
+ ```ここに言語を入力
10
+
11
+ class UsersController < ApplicationController
12
+
13
+
14
+
15
+ def index
16
+
17
+ @users = User.all
18
+
19
+ @user = User.new
20
+
21
+ end
22
+
23
+
24
+
25
+ def show
26
+
27
+ @user = User.find(params[:id])
28
+
29
+ end
30
+
31
+
32
+
33
+ def new
34
+
35
+ @user = User.new
36
+
37
+ end
38
+
39
+
40
+
41
+ def create
42
+
43
+ @user = User.new(user_params)
44
+
45
+ if @user.save
46
+
47
+ redirect_to user_path(@user)
48
+
49
+ else
50
+
51
+ render :new
52
+
53
+ end
54
+
55
+ end
56
+
57
+
58
+
59
+ def edit
60
+
61
+ @user = User.find(params[:id])
62
+
63
+ end
64
+
65
+
66
+
67
+ def update
68
+
69
+ @user = User.find(params[:id])
70
+
71
+ if @user.update(user_params)
72
+
73
+ redirect_to user_path(@user)
74
+
75
+ else
76
+
77
+ render :edit
78
+
79
+ end
80
+
81
+ end
82
+
83
+
84
+
85
+ def library
86
+
87
+ end
88
+
89
+
90
+
91
+ private
92
+
93
+
94
+
95
+ def user_params
96
+
97
+ params.require(:user).permit(:id, :name, :img, :email, :password, :password_confirmation)
98
+
99
+ end
100
+
101
+
102
+
103
+ def after_sign_up_path_for(resource)
104
+
105
+ "/user/#{current_user.id}"
106
+
107
+ end
108
+
109
+
110
+
111
+ def after_sign_out_path_for(resource)
112
+
113
+ users_index_path
114
+
115
+ end
116
+
117
+
118
+
119
+ end
120
+
121
+
122
+
123
+ ```
124
+
125
+
126
+
127
+
128
+
129
+ ```ここに言語を入力
130
+
131
+ (<% provide(:title, "Edit user") %>
132
+
133
+
134
+
135
+ <div class="py-4">
136
+
137
+ <div class="container">
138
+
139
+ <h1 class="text-center">Update your profile</h1>
140
+
141
+ <div class="row justify-content-center">
142
+
143
+ <div class="col-md-6 col-md-offset-3">
144
+
145
+
146
+
147
+ <%= form_with model: @user, url: { action: "update" } do |f| %>
148
+
149
+ <%= f.label :name %>
150
+
151
+ <%= f.text_field :name, class: 'form-control' %>
152
+
153
+
154
+
155
+ <%= f.label :email %>
156
+
157
+ <%= f.email_field :email, class: 'form-control' %>
158
+
159
+
160
+
161
+ <%#= f.label :password, "New password" %>
162
+
163
+ <%#= f.password_field :password, class: 'form-control' %>
164
+
165
+
166
+
167
+ <%#= f.label :password_confirmation, "Confirmation" %>
168
+
169
+ <%#= f.password_field :password_confirmation, class: 'form-control' %>
170
+
171
+
172
+
173
+ <%= f.label :img %>
174
+
175
+ <%= f.file_field :img %>
176
+
177
+
178
+
179
+ <div class="actions">
180
+
181
+ <%= f.submit "Save changes", class: "btn btn-primary" %>
182
+
183
+ </div>
184
+
185
+ <% end %>
186
+
187
+ </div>
188
+
189
+ </div>
190
+
191
+ </div>
192
+
193
+ </div>)
194
+
195
+ ```
196
+
197
+
198
+
199
+
200
+
201
+
202
+
203
+
204
+
205
+
206
+
207
+ ```ここに言語を入力
208
+
209
+ Rails.application.routes.draw do
210
+
211
+
212
+
213
+ devise_for :users, controllers: { sessions: 'users/sessions' }
214
+
215
+
216
+
217
+ devise_scope :user do
218
+
219
+ get "users/show", :to => "users/user_id#show"
220
+
221
+ get "user/id", :to => "users/registration#detail"
222
+
223
+ get "signup", :to => "users/registrations#new"
224
+
225
+ get "sign_in", :to => "devise/sessions#new"
226
+
227
+ get "login", :to => "users/sessions#new"
228
+
229
+ end
230
+
231
+
232
+
233
+ root to: 'pages#index'
234
+
235
+
236
+
237
+ resources :users
238
+
239
+ resources :posts do
240
+
241
+ resources :comments, only: [:create]
242
+
243
+ end
244
+
245
+ get "users/library"
246
+
247
+ get "pages/index"
248
+
249
+
250
+
251
+ end