質問編集履歴
2
accountの章をやり直してmergeにトライしましたが、またもエラーが出ました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,5 +1,19 @@
|
|
1
1
|
```ここに言語を入力
|
2
2
|
|
3
|
+
$ git merge account-activation
|
4
|
+
|
5
|
+
error: cannot stat 'app/views/user_mailer': Permission denied
|
6
|
+
|
7
|
+
error: cannot stat 'app/views/user_mailer': Permission denied
|
8
|
+
|
9
|
+
error: cannot stat 'app/views/user_mailer': Permission denied
|
10
|
+
|
11
|
+
error: cannot stat 'app/views/user_mailer': Permission denied
|
12
|
+
|
13
|
+
Updating a79ce83..323d78c
|
14
|
+
|
15
|
+
``````ここに言語を入力
|
16
|
+
|
3
17
|
↓ new.html.erb
|
4
18
|
|
5
19
|
|
1
views/users/new.html.erb .._form.html.erb app/users/controllerの3コードを入れました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,4 +1,232 @@
|
|
1
|
+
```ここに言語を入力
|
2
|
+
|
3
|
+
↓ new.html.erb
|
4
|
+
|
5
|
+
|
6
|
+
|
7
|
+
<% provide(:title, 'Sign up') %>
|
8
|
+
|
9
|
+
<% provide(:button_text, 'Create my account') %>
|
10
|
+
|
11
|
+
<h1>Sign up</h1>
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
<div class="row">
|
16
|
+
|
17
|
+
<div class="col-md-6 col-md-offset-3">
|
18
|
+
|
19
|
+
<%= render 'form' %>
|
20
|
+
|
21
|
+
</div>
|
22
|
+
|
23
|
+
</div>
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
↓ _form.html.erb
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
<%= form_for(@user, url: yield(:url)) do |f| %>
|
32
|
+
|
33
|
+
<%= render 'shared/error_messages', object: @user %>
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
<%= f.label :name %>
|
38
|
+
|
39
|
+
<%= f.text_field :name, class: 'form-control' %>
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
<%= f.label :email %>
|
44
|
+
|
45
|
+
<%= f.email_field :email, class: 'form-control' %>
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
<%= f.label :password %>
|
50
|
+
|
51
|
+
<%= f.password_field :password, class: 'form-control' %>
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
<%= f.label :password_confirmation %>
|
56
|
+
|
57
|
+
<%= f.password_field :password_confirmation, class: 'form-control' %>
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
<%= f.submit yield(:button_text), class: "btn btn-primary" %>
|
62
|
+
|
63
|
+
<% end %>
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
↓ contoroller
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
class UsersController < ApplicationController
|
72
|
+
|
73
|
+
before_action :logged_in_user, only: [:index, :edit, :update, :destroy]
|
74
|
+
|
75
|
+
before_action :correct_user, only: [:edit, :update]
|
76
|
+
|
77
|
+
before_action :admin_user, only: :destroy
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
def index
|
82
|
+
|
83
|
+
@users = User.where(activated: true).paginate(page: params[:page])
|
84
|
+
|
85
|
+
end
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
def show
|
90
|
+
|
91
|
+
@user = User.find(params[:id])
|
92
|
+
|
93
|
+
redirect_to root_url and return unless @user.activated?
|
94
|
+
|
95
|
+
end
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
def new
|
100
|
+
|
101
|
+
@user = User.new
|
102
|
+
|
103
|
+
end
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
def create
|
108
|
+
|
109
|
+
@user = User.new(user_params)
|
110
|
+
|
111
|
+
if @user.save
|
112
|
+
|
113
|
+
@user.send_activation_email
|
114
|
+
|
115
|
+
#UserMailer.account_activation(@user).deliver_now
|
116
|
+
|
117
|
+
flash[:info] = "Please check your email to activate your account."
|
118
|
+
|
119
|
+
redirect_to root_url
|
120
|
+
|
121
|
+
else
|
122
|
+
|
123
|
+
render 'new'
|
124
|
+
|
125
|
+
end
|
126
|
+
|
127
|
+
end
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
def edit
|
132
|
+
|
133
|
+
end
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
def update
|
138
|
+
|
139
|
+
if @user.update_attributes(user_params)
|
140
|
+
|
141
|
+
flash[:success] = "Profile updated"
|
142
|
+
|
143
|
+
redirect_to @user
|
144
|
+
|
145
|
+
else
|
146
|
+
|
147
|
+
render 'edit'
|
148
|
+
|
149
|
+
end
|
150
|
+
|
151
|
+
end
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
def destroy
|
156
|
+
|
157
|
+
User.find(params[:id]).destroy
|
158
|
+
|
159
|
+
flash[:success] = "User deleted"
|
160
|
+
|
161
|
+
redirect_to users_url
|
162
|
+
|
163
|
+
end
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
private
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
def user_params
|
172
|
+
|
173
|
+
params.require(:user).permit(:name, :email, :password,
|
174
|
+
|
175
|
+
:password_confirmation)
|
176
|
+
|
177
|
+
end
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
#beforeアクション
|
182
|
+
|
183
|
+
|
184
|
+
|
185
|
+
#ログイン済みユーザーかどうか確認
|
186
|
+
|
187
|
+
def logged_in_user
|
188
|
+
|
189
|
+
unless logged_in?
|
190
|
+
|
191
|
+
store_location
|
192
|
+
|
193
|
+
flash[:danger] = "please log in."
|
194
|
+
|
195
|
+
redirect_to login_url
|
196
|
+
|
197
|
+
end
|
198
|
+
|
199
|
+
end
|
200
|
+
|
201
|
+
|
202
|
+
|
203
|
+
#正しいユーザーかどうか確認
|
204
|
+
|
205
|
+
def correct_user
|
206
|
+
|
207
|
+
@user = User.find(params[:id])
|
208
|
+
|
209
|
+
redirect_to(root_url) unless current_user?(@user)
|
210
|
+
|
211
|
+
end
|
212
|
+
|
213
|
+
|
214
|
+
|
215
|
+
#管理者かどうか確認
|
216
|
+
|
217
|
+
def admin_user
|
218
|
+
|
219
|
+
redirect_to(root_url) unless current_user.admin?
|
220
|
+
|
221
|
+
end
|
222
|
+
|
223
|
+
end
|
224
|
+
|
225
|
+
|
226
|
+
|
227
|
+
|
228
|
+
|
1
|
-
### 前提・実現したいこと
|
229
|
+
```### 前提・実現したいこと
|
2
230
|
|
3
231
|
|
4
232
|
|