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
5ad6e140
Commit
5ad6e140
authored
Nov 21, 2019
by
Đường Sỹ Hoàng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed coding styles
parent
4348edea
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
10 deletions
+13
-10
app/controllers/application_controller.rb
+7
-7
app/models/micropost.rb
+4
-1
app/views/static_pages/home.html.erb
+2
-2
No files found.
app/controllers/application_controller.rb
View file @
5ad6e140
...
@@ -4,12 +4,12 @@ class ApplicationController < ActionController::Base
...
@@ -4,12 +4,12 @@ class ApplicationController < ActionController::Base
private
private
# Confirms a logged-in user.
# Confirms a logged-in user.
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
end
end
app/models/micropost.rb
View file @
5ad6e140
class
Micropost
<
ApplicationRecord
class
Micropost
<
ApplicationRecord
belongs_to
:user
default_scope
->
{
order
(
created_at: :desc
)
}
default_scope
->
{
order
(
created_at: :desc
)
}
mount_uploader
:picture
,
PictureUploader
mount_uploader
:picture
,
PictureUploader
belongs_to
:user
validates
:user_id
,
presence:
true
validates
:user_id
,
presence:
true
validates
:content
,
presence:
true
,
length:
{
maximum:
140
}
validates
:content
,
presence:
true
,
length:
{
maximum:
140
}
validate
:picture_size
validate
:picture_size
...
...
app/views/static_pages/home.html.erb
View file @
5ad6e140
...
@@ -17,8 +17,8 @@
...
@@ -17,8 +17,8 @@
</div>
</div>
</div>
</div>
<%
else
%>
<%
else
%>
<div
class=
"center jumbotron"
>
<div
class=
"center jumbotron"
>
<h1>
Welcome to the Sample App
</h1>
<h1>
Welcome to the Sample App
</h1>
<h2>
<h2>
This is the home page for the
This is the home page for the
...
...
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