Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
sample_app
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nguyen Hoang Mai Phuong
sample_app
Commits
170e6813
Commit
170e6813
authored
Jun 23, 2021
by
Nguyen Hoang Mai Phuong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix style code
parent
442df614
Pipeline
#1291
failed with stages
in 0 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
44 additions
and
58 deletions
+44
-58
app/controllers/users_controller.rb
+24
-24
app/views/users/_form.html.erb
+18
-0
app/views/users/edit.html.erb
+1
-17
app/views/users/new.html.erb
+1
-17
No files found.
app/controllers/users_controller.rb
View file @
170e6813
...
@@ -3,8 +3,8 @@ class UsersController < ApplicationController
...
@@ -3,8 +3,8 @@ class UsersController < ApplicationController
before_action
:logged_in_user
,
only:
[
:index
,
:edit
,
:update
,
:destroy
]
before_action
:logged_in_user
,
only:
[
:index
,
:edit
,
:update
,
:destroy
]
before_action
:correct_user
,
only:
[
:edit
,
:update
]
before_action
:correct_user
,
only:
[
:edit
,
:update
]
before_action
:admin_user
,
before_action
:admin_user
,
only: :destroy
only: :destroy
def
show
def
show
@user
=
User
.
find
(
params
[
:id
])
@user
=
User
.
find
(
params
[
:id
])
end
end
...
@@ -44,32 +44,32 @@ class UsersController < ApplicationController
...
@@ -44,32 +44,32 @@ class UsersController < ApplicationController
end
end
private
private
def
user_params
params
.
require
(
:user
).
permit
(
:name
,
:email
,
:password
,
:password_confirmation
)
end
def
user_params
params
.
require
(
:user
).
permit
(
:name
,
:email
,
:password
,
:password_confirmation
)
end
def
logged_in_user
def
logged_in_user
unless
logged_in?
unless
logged_in?
store_location
store_location
flash
[
:danger
]
=
"Please log in."
flash
[
:danger
]
=
"Please log in."
redirect_to
login_url
redirect_to
login_url
end
end
end
end
def
correct_user
def
correct_user
@user
=
User
.
find
(
params
[
:id
])
@user
=
User
.
find
(
params
[
:id
])
redirect_to
(
root_url
)
unless
current_user?
(
@user
)
redirect_to
(
root_url
)
unless
current_user?
(
@user
)
end
end
def
destroy
def
destroy
User
.
find
(
params
[
:id
]).
destroy
User
.
find
(
params
[
:id
]).
destroy
flash
[
:success
]
=
"User deleted"
flash
[
:success
]
=
"User deleted"
redirect_to
users_url
redirect_to
users_url
end
end
# Confirms an admin user.
# Confirms an admin user.
def
admin_user
def
admin_user
redirect_to
(
root_url
)
unless
current_user
.
admin?
redirect_to
(
root_url
)
unless
current_user
.
admin?
end
end
end
end
app/views/users/_form.html.erb
0 → 100644
View file @
170e6813
<%=
form_with
(
model:
@user
,
local:
true
)
do
|
f
|
%>
<%=
render
'shared/error_messages'
,
object:
@user
%>
<%=
f
.
label
:name
%>
<%=
f
.
text_field
:name
,
class:
'form-control'
%>
<%=
f
.
label
:email
%>
<%=
f
.
email_field
:email
,
class:
'form-control'
%>
<%=
f
.
label
:password
%>
<%=
f
.
password_field
:password
,
class:
'form-control'
%>
<%=
f
.
label
:password_confirmation
%>
<%=
f
.
password_field
:password_confirmation
,
class:
'form-control'
%>
<%=
f
.
submit
yield
(
:button_text
),
class:
"btn btn-primary"
%>
<%
end
%>
\ No newline at end of file
app/views/users/edit.html.erb
View file @
170e6813
...
@@ -2,23 +2,7 @@
...
@@ -2,23 +2,7 @@
<h1>
Update your profile
</h1>
<h1>
Update your profile
</h1>
<div
class=
"row"
>
<div
class=
"row"
>
<div
class=
"col-md-6 offset-md-3"
>
<div
class=
"col-md-6 offset-md-3"
>
<%=
form_with
(
model:
@user
,
local:
true
)
do
|
f
|
%>
<%=
render
'form'
%>
<%=
render
'shared/error_messages'
%>
<%=
f
.
label
:name
%>
<%=
f
.
text_field
:name
,
class:
'form-control'
%>
<%=
f
.
label
:email
%>
<%=
f
.
email_field
:email
,
class:
'form-control'
%>
<%=
f
.
label
:password
%>
<%=
f
.
password_field
:password
,
class:
'form-control'
%>
<%=
f
.
label
:password_confirmation
,
"Confirmation"
%>
<%=
f
.
password_field
:password_confirmation
,
class:
'form-control'
%>
<%=
f
.
submit
"Save changes"
,
class:
"btn btn-primary"
%>
<%
end
%>
<div
class=
"gravatar_edit"
>
<div
class=
"gravatar_edit"
>
<%=
gravatar_for
@user
%>
<%=
gravatar_for
@user
%>
<a
href=
"https://gravatar.com/emails"
target=
"_blank"
>
change
</a>
<a
href=
"https://gravatar.com/emails"
target=
"_blank"
>
change
</a>
...
...
app/views/users/new.html.erb
View file @
170e6813
...
@@ -2,22 +2,6 @@
...
@@ -2,22 +2,6 @@
<h1>
Sign up
</h1>
<h1>
Sign up
</h1>
<div
class=
"row"
>
<div
class=
"row"
>
<div
class=
"col-md-6 offset-md-3"
>
<div
class=
"col-md-6 offset-md-3"
>
<%=
form_with
(
model:
@user
,
local:
true
)
do
|
f
|
%>
<%=
render
'form'
%>
<%=
render
'shared/error_messages'
%>
<%=
f
.
label
:name
%>
<%=
f
.
text_field
:name
,
class:
'form-control'
%>
<%=
f
.
label
:email
%>
<%=
f
.
email_field
:email
,
class:
'form-control'
%>
<%=
f
.
label
:password
%>
<%=
f
.
password_field
:password
,
class:
'form-control'
%>
<%=
f
.
label
:password_confirmation
,
"Confirmation"
%>
<%=
f
.
password_field
:password_confirmation
,
class:
'form-control'
%>
<%=
f
.
submit
"Create my account"
,
class:
"btn btn-primary"
%>
<%
end
%>
</div>
</div>
</div>
</div>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment