質問編集履歴
1
<code>に変更
title
CHANGED
File without changes
|
body
CHANGED
@@ -2,12 +2,125 @@
|
|
2
2
|
postはされているのですがどこが理解出来ていないのかわかっていない状況です
|
3
3
|
お力添え頂けると幸いです!
|
4
4
|
|
5
|
+
```ここに言語を入力
|
5
|
-
|
6
|
+
class UsersController < ApplicationController
|
6
7
|
|
8
|
+
def index
|
9
|
+
@users = User.all
|
7
|
-
|
10
|
+
@user = User.new
|
11
|
+
end
|
8
12
|
|
13
|
+
def show
|
9
|
-
|
14
|
+
@user = User.find(params[:id])
|
15
|
+
end
|
10
16
|
|
17
|
+
def new
|
11
|
-
|
18
|
+
@user = User.new
|
19
|
+
end
|
12
20
|
|
21
|
+
def create
|
22
|
+
@user = User.new(user_params)
|
23
|
+
if @user.save
|
24
|
+
redirect_to user_path(@user)
|
25
|
+
else
|
26
|
+
render :new
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def edit
|
31
|
+
@user = User.find(params[:id])
|
32
|
+
end
|
33
|
+
|
34
|
+
def update
|
35
|
+
@user = User.find(params[:id])
|
36
|
+
if @user.update(user_params)
|
37
|
+
redirect_to user_path(@user)
|
38
|
+
else
|
39
|
+
render :edit
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def library
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
def user_params
|
49
|
+
params.require(:user).permit(:id, :name, :img, :email, :password, :password_confirmation)
|
50
|
+
end
|
51
|
+
|
52
|
+
def after_sign_up_path_for(resource)
|
13
|
-
|
53
|
+
"/user/#{current_user.id}"
|
54
|
+
end
|
55
|
+
|
56
|
+
def after_sign_out_path_for(resource)
|
57
|
+
users_index_path
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
```
|
63
|
+
|
64
|
+
|
65
|
+
```ここに言語を入力
|
66
|
+
(<% provide(:title, "Edit user") %>
|
67
|
+
|
68
|
+
<div class="py-4">
|
69
|
+
<div class="container">
|
70
|
+
<h1 class="text-center">Update your profile</h1>
|
71
|
+
<div class="row justify-content-center">
|
72
|
+
<div class="col-md-6 col-md-offset-3">
|
73
|
+
|
74
|
+
<%= form_with model: @user, url: { action: "update" } do |f| %>
|
75
|
+
<%= f.label :name %>
|
76
|
+
<%= f.text_field :name, class: 'form-control' %>
|
77
|
+
|
78
|
+
<%= f.label :email %>
|
79
|
+
<%= f.email_field :email, class: 'form-control' %>
|
80
|
+
|
81
|
+
<%#= f.label :password, "New password" %>
|
82
|
+
<%#= f.password_field :password, class: 'form-control' %>
|
83
|
+
|
84
|
+
<%#= f.label :password_confirmation, "Confirmation" %>
|
85
|
+
<%#= f.password_field :password_confirmation, class: 'form-control' %>
|
86
|
+
|
87
|
+
<%= f.label :img %>
|
88
|
+
<%= f.file_field :img %>
|
89
|
+
|
90
|
+
<div class="actions">
|
91
|
+
<%= f.submit "Save changes", class: "btn btn-primary" %>
|
92
|
+
</div>
|
93
|
+
<% end %>
|
94
|
+
</div>
|
95
|
+
</div>
|
96
|
+
</div>
|
97
|
+
</div>)
|
98
|
+
```
|
99
|
+
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
|
104
|
+
```ここに言語を入力
|
105
|
+
Rails.application.routes.draw do
|
106
|
+
|
107
|
+
devise_for :users, controllers: { sessions: 'users/sessions' }
|
108
|
+
|
109
|
+
devise_scope :user do
|
110
|
+
get "users/show", :to => "users/user_id#show"
|
111
|
+
get "user/id", :to => "users/registration#detail"
|
112
|
+
get "signup", :to => "users/registrations#new"
|
113
|
+
get "sign_in", :to => "devise/sessions#new"
|
114
|
+
get "login", :to => "users/sessions#new"
|
115
|
+
end
|
116
|
+
|
117
|
+
root to: 'pages#index'
|
118
|
+
|
119
|
+
resources :users
|
120
|
+
resources :posts do
|
121
|
+
resources :comments, only: [:create]
|
122
|
+
end
|
123
|
+
get "users/library"
|
124
|
+
get "pages/index"
|
125
|
+
|
126
|
+
end
|