質問編集履歴
3
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -68,6 +68,8 @@
|
|
68
68
|
|
69
69
|
|
70
70
|
|
71
|
+
|
72
|
+
|
71
73
|
users_contoroller.rb
|
72
74
|
|
73
75
|
|
@@ -128,7 +130,75 @@
|
|
128
130
|
|
129
131
|
|
130
132
|
|
131
|
-
|
133
|
+
users/view/edit.html.haml
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
.profile__right__content__edit
|
138
|
+
|
139
|
+
= form_with model: @user, local: true do |f|
|
140
|
+
|
141
|
+
= f.label :image, class: "file", id: 'user_img' do
|
142
|
+
|
143
|
+
-if @user.image.present?
|
144
|
+
|
145
|
+
.profile-content__edit__view-box
|
146
|
+
|
147
|
+
= image_tag @user.image.to_s, alt: "プロフィール画像",size: "60x60", class: 'mypage__icon', id: :img_prev
|
148
|
+
|
149
|
+
.profile-content__edit__nickname
|
150
|
+
|
151
|
+
= f.text_field :nickname, class: 'profile__right__input__nickname',value: @user.nickname
|
152
|
+
|
153
|
+
.profile-content__edit__email
|
154
|
+
|
155
|
+
= f.email_field :email, class: 'profile__right__input__email'
|
156
|
+
|
157
|
+
.profile-content__edit__password
|
158
|
+
|
159
|
+
= f.password_field :password
|
160
|
+
|
161
|
+
新しいパスワード
|
162
|
+
|
163
|
+
.profile-content__edit__password-confirmation
|
164
|
+
|
165
|
+
= f.password_field :password_confirmation
|
166
|
+
|
167
|
+
新しいパスワード確認
|
168
|
+
|
169
|
+
-else
|
170
|
+
|
171
|
+
.profile-content__edit__view-box
|
172
|
+
|
173
|
+
-# = image_tag "noimage.jpeg", alt: "プロフィール画像",size: "60x60", class: 'mypage__icon'
|
174
|
+
|
175
|
+
.profile-content__edit__nickname
|
176
|
+
|
177
|
+
= f.text_field :nickname, class: 'profile__right__input__nickname',value: @user.nickname
|
178
|
+
|
179
|
+
.profile-content__edit__email
|
180
|
+
|
181
|
+
= f.email_field :email, class: 'profile__right__input__email'
|
182
|
+
|
183
|
+
.profile-content__edit__password
|
184
|
+
|
185
|
+
= f.password_field :password
|
186
|
+
|
187
|
+
新しいパスワード
|
188
|
+
|
189
|
+
.profile-content__edit__password-confirmation
|
190
|
+
|
191
|
+
= f.password_field :password_confirmation
|
192
|
+
|
193
|
+
新しいパスワード確認
|
194
|
+
|
195
|
+
= f.file_field :image,class: 'file'
|
196
|
+
|
197
|
+
.profile__right__content__bottom
|
198
|
+
|
199
|
+
.profile__right__content__profile
|
200
|
+
|
201
|
+
= f.submit '変更する', class: 'profile__right__input__send'
|
132
202
|
|
133
203
|
```
|
134
204
|
|
2
書式の修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -66,8 +66,6 @@
|
|
66
66
|
|
67
67
|
end
|
68
68
|
|
69
|
-
```
|
70
|
-
|
71
69
|
|
72
70
|
|
73
71
|
users_contoroller.rb
|
@@ -130,6 +128,14 @@
|
|
130
128
|
|
131
129
|
|
132
130
|
|
131
|
+
|
132
|
+
|
133
|
+
```
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
|
138
|
+
|
133
139
|
### 試したこと
|
134
140
|
|
135
141
|
|
1
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -70,6 +70,66 @@
|
|
70
70
|
|
71
71
|
|
72
72
|
|
73
|
+
users_contoroller.rb
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
class UsersController < ApplicationController
|
78
|
+
|
79
|
+
def show
|
80
|
+
|
81
|
+
@user = User.find(params[:id])
|
82
|
+
|
83
|
+
@posts = @user.posts
|
84
|
+
|
85
|
+
end
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
def edit
|
90
|
+
|
91
|
+
@user = User.find(params[:id])
|
92
|
+
|
93
|
+
end
|
94
|
+
|
95
|
+
def update
|
96
|
+
|
97
|
+
@user = User.find(params[:id])
|
98
|
+
|
99
|
+
if @user.update(user_params)
|
100
|
+
|
101
|
+
flash[:notice] = "変更を保存しました"
|
102
|
+
|
103
|
+
redirect_to user_path(current_user)
|
104
|
+
|
105
|
+
else
|
106
|
+
|
107
|
+
flash[:alert] = "編集の保存に失敗しました"
|
108
|
+
|
109
|
+
render :edit
|
110
|
+
|
111
|
+
end
|
112
|
+
|
113
|
+
end
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
private
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
def user_params
|
122
|
+
|
123
|
+
params.require(:user).permit(:nickname, :email, :image)
|
124
|
+
|
125
|
+
end
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
end
|
130
|
+
|
131
|
+
|
132
|
+
|
73
133
|
### 試したこと
|
74
134
|
|
75
135
|
|