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
Đường Sỹ Hoàng
sample_app
Commits
d918dc16
Commit
d918dc16
authored
Nov 22, 2019
by
Đường Sỹ Hoàng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed unuse file
parent
5ad6e140
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
13 additions
and
53 deletions
+13
-53
app/controllers/users_controller.rb
+2
-12
app/helpers/microposts_helper.rb
+0
-2
app/models/micropost.rb
+4
-4
app/models/user.rb
+1
-1
app/views/microposts/_micropost.html.erb
+1
-1
app/views/users/edit.html.erb
+4
-21
app/views/users/new.html.erb
+1
-12
No files found.
app/controllers/users_controller.rb
View file @
d918dc16
...
...
@@ -9,12 +9,13 @@ class UsersController < ApplicationController
def
show
@user
=
User
.
find
(
params
[
:id
])
redirect_to
root_url
and
return
unless
@user
.
activated
@microposts
=
@user
.
microposts
.
paginate
(
page:
params
[
:page
])
end
def
new
@user
=
User
.
new
end
end
def
create
@user
=
User
.
new
(
user_params
)
...
...
@@ -71,17 +72,6 @@ class UsersController < ApplicationController
params
.
require
(
:user
).
permit
(
:name
,
:email
,
:password
,
:password_confirmation
)
end
# Before filters
# Confirms a logged-in user.
def
logged_in_user
unless
logged_in?
store_location
flash
[
:danger
]
=
"Please log in."
redirect_to
login_url
end
end
# Confirms the correct user.
def
correct_user
@user
=
User
.
find
(
params
[
:id
])
...
...
app/helpers/microposts_helper.rb
deleted
100644 → 0
View file @
5ad6e140
module
MicropostsHelper
end
app/models/micropost.rb
View file @
d918dc16
...
...
@@ -12,9 +12,9 @@ class Micropost < ApplicationRecord
private
# Validates the size of an uploaded picture.
def
picture_size
if
picture
.
size
>
5
.
megabytes
errors
.
add
(
:picture
,
"should be less than 5MB"
)
end
def
picture_size
if
picture
.
size
>
5
.
megabytes
errors
.
add
(
:picture
,
"should be less than 5MB"
)
end
end
end
app/models/user.rb
View file @
d918dc16
...
...
@@ -24,7 +24,7 @@ class User < ApplicationRecord
has_secure_password
class
<<
self
# Returns the hash digest of the given string.
# Returns the hash digest of the given string.
def
digest
(
string
)
cost
=
ActiveModel
::
SecurePassword
.
min_cost
?
BCrypt
::
Engine
::
MIN_COST
:
BCrypt
::
Engine
.
cost
BCrypt
::
Password
.
create
(
string
,
cost:
cost
)
...
...
app/views/microposts/_micropost.html.erb
View file @
d918dc16
...
...
@@ -8,7 +8,7 @@
<span
class=
"timestamp"
>
Posted
<%=
time_ago_in_words
(
micropost
.
created_at
)
%>
ago.
<%
if
current_user?
(
micropost
.
user
)
%>
<%=
link_to
"delete"
,
micropost
,
method: :delete
,
data:
{
confirm:
"You sure?"
}
%>
<%=
link_to
"delete"
,
micropost
,
method: :delete
,
data:
{
confirm:
"You sure?"
}
%>
<%
end
%>
</span>
</li>
app/views/users/edit.html.erb
View file @
d918dc16
...
...
@@ -3,27 +3,10 @@
<div
class=
"row"
>
<div
class=
"col-md-6 col-md-offset-3"
>
<%=
form_for
(
@user
)
do
|
f
|
%>
<%=
render
"shared/error_messages"
,
object:
f
.
object
%>
<%=
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"
>
<%=
gravatar_for
@user
%>
<a
href=
"http://gravatar.com/emails"
>
change
</a>
<%=
render
"form"
%>
<div
class=
"gravatar_edit"
>
<%=
gravatar_for
@user
%>
<a
href=
"http://gravatar.com/emails"
>
change
</a>
</div>
</div>
</div>
app/views/users/new.html.erb
View file @
d918dc16
...
...
@@ -3,17 +3,6 @@
<div
class=
"row"
>
<div
class=
"col-md-6 col-md-offset-3"
>
<%=
form_for
(
@user
)
do
|
f
|
%>
<%=
render
"shared/error_messages"
,
object:
f
.
object
%>
<%=
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
%>
<%=
render
"form"
%>
</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