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
4d61c3cc
Commit
4d61c3cc
authored
Jun 15, 2021
by
Nguyen Hoang Mai Phuong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use SSL and the Puma webserver in production
parent
188a6c3f
Pipeline
#1266
failed with stages
in 0 seconds
Changes
10
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
175 additions
and
11 deletions
+175
-11
app/assets/stylesheets/custom.scss
+78
-8
app/controllers/users_controller.rb
+22
-0
app/helpers/users_helper.rb
+7
-0
app/views/layouts/application.html.erb
+5
-0
app/views/shared/_error_messages.html.erb
+13
-0
app/views/users/new.html.erb
+23
-2
app/views/users/show.html.erb
+12
-0
config/database.yml
+10
-0
config/environments/development.rb
+4
-0
config/routes.rb
+1
-1
No files found.
app/assets/stylesheets/custom.scss
View file @
4d61c3cc
@import
"bootstrap"
;
@import
"bootstrap"
;
.center
{
.center
{
text-align
:
center
;
text-align
:
center
;
}
h1
{
margin-bottom
:
10px
;
.center
h1
{
}
margin-bottom
:
10px
;
}
}
/* typography */
/* typography */
...
@@ -55,10 +54,6 @@ p {
...
@@ -55,10 +54,6 @@ p {
padding
:
4px
10px
;
padding
:
4px
10px
;
}
}
img
{
display
:
none
;
}
.jumbotron
{
.jumbotron
{
border-bottom
:
10%
;
border-bottom
:
10%
;
background-color
:
#dadada
;
background-color
:
#dadada
;
...
@@ -67,3 +62,78 @@ img {
...
@@ -67,3 +62,78 @@ img {
border-bottom-left-radius
:
10px
;
border-bottom-left-radius
:
10px
;
}
}
@mixin
box_sizing
{
-moz-box-sizing
:
border-box
;
-webkit-box-sizing
:
border-box
;
box-sizing
:
border-box
;
}
/* miscellaneous */
.debug_dump
{
clear
:
both
;
float
:
left
;
width
:
100%
;
margin-top
:
45px
;
@include
box_sizing
;
}
/* sidebar */
aside
{
section
.user_info
{
margin-top
:
20px
;
}
section
{
padding
:
10px
0
;
margin-top
:
20px
;
&
:first-child
{
border
:
0
;
padding-top
:
0
;
}
span
{
display
:
block
;
margin-bottom
:
3px
;
line-height
:
1
;
}
h1
{
font-size
:
1
.4em
;
text-align
:
left
;
letter-spacing
:
-1px
;
margin-bottom
:
3px
;
margin-top
:
0px
;
}
}
}
.gravatar
{
float
:
left
;
margin-right
:
10px
;
}
.gravatar_edit
{
margin-top
:
15px
;
}
/* forms */
input
,
textarea
,
select
,
.uneditable-input
{
border
:
1px
solid
#bbb
;
width
:
100%
;
margin-bottom
:
15px
;
@include
box_sizing
;
}
input
{
height
:
auto
!
important
;
}
#error_explanation
{
color
:
red
;
ul
{
color
:
red
;
margin
:
0
0
30px
0
;
}
}
.field_with_errors
{
.form-control
{
color
:
$danger
;
}
}
app/controllers/users_controller.rb
View file @
4d61c3cc
class
UsersController
<
ApplicationController
class
UsersController
<
ApplicationController
def
show
@user
=
User
.
find
(
params
[
:id
])
end
def
new
def
new
@user
=
User
.
new
end
def
create
@user
=
User
.
new
(
user_params
)
if
@user
.
save
flash
[
:success
]
=
"Welcome to the Sample App!"
redirect_to
@user
# Handle a successful save.
else
render
'new'
end
end
private
def
user_params
params
.
require
(
:user
).
permit
(
:name
,
:email
,
:password
,
:password_confirmation
)
end
end
end
end
app/helpers/users_helper.rb
View file @
4d61c3cc
module
UsersHelper
module
UsersHelper
# Returns the Gravatar for the given user.
def
gravatar_for
(
user
,
options
=
{
size:
80
})
size
=
options
[
:size
]
gravatar_id
=
Digest
::
MD5
::
hexdigest
(
user
.
email
.
downcase
)
gravatar_url
=
"https://secure.gravatar.com/avatar/
#{
gravatar_id
}
?s=
#{
size
}
"
image_tag
(
gravatar_url
,
alt:
user
.
name
,
class:
"gravatar"
)
end
end
end
app/views/layouts/application.html.erb
View file @
4d61c3cc
...
@@ -13,8 +13,12 @@
...
@@ -13,8 +13,12 @@
<body>
<body>
<%=
render
'layouts/header'
%>
<%=
render
'layouts/header'
%>
<div
class=
"container"
>
<div
class=
"container"
>
<%
flash
.
each
do
|
message_type
,
message
|
%>
<div
class=
"alert alert-
<%=
message_type
%>
"
>
<%=
message
%>
</div>
<%
end
%>
<%=
yield
%>
<%=
yield
%>
</div>
</div>
<%=
render
'layouts/footer'
%>
<%=
render
'layouts/footer'
%>
<%=
debug
(
params
)
if
Rails
.
env
.
development?
%>
</body>
</body>
</html>
</html>
\ No newline at end of file
app/views/shared/_error_messages.html.erb
0 → 100644
View file @
4d61c3cc
<%
if
@user
.
errors
.
any?
%>
<div
id=
"error_explanation"
>
<div
class=
"alert alert-danger"
role=
"alert"
>
The form contains
<%=
pluralize
(
@user
.
errors
.
count
,
"error"
)
%>
.
</div>
<ul>
<%
@user
.
errors
.
full_messages
.
each
do
|
msg
|
%>
<li>
<%=
msg
%>
</li>
<%
end
%>
</ul>
</div>
<%
end
%>
\ No newline at end of file
app/views/users/new.html.erb
View file @
4d61c3cc
<h1>
Users#new
</h1>
<%
provide
(
:title
,
'Sign up'
)
%>
<p>
Find me in app/views/users/new.html.erb
</p>
<h1>
Sign up
</h1>
<div
class=
"row"
>
<div
class=
"col-md-6 offset-md-3"
>
<%=
form_with
(
model:
@user
,
local:
true
)
do
|
f
|
%>
<%=
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>
app/views/users/show.html.erb
0 → 100644
View file @
4d61c3cc
<%
provide
(
:title
,
@user
.
name
)
%>
<div
class=
"row"
>
<aside
class=
"col-md-4"
>
<section
class=
"user_info"
>
<h1>
<%=
gravatar_for
@user
%>
<%=
@user
.
name
%>
</h1>
</section>
</aside>
</div>
\ No newline at end of file
config/database.yml
View file @
4d61c3cc
...
@@ -23,3 +23,13 @@ test:
...
@@ -23,3 +23,13 @@ test:
production
:
production
:
<<
:
*default
<<
:
*default
database
:
db/production.sqlite3
database
:
db/production.sqlite3
production
:
adapter
:
postgresql
encoding
:
unicode
# For details on connection pooling, see Rails configuration guide
# https://guides.rubyonrails.org/configuring.html#database-pooling
pool
:
<%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
database
:
sample_app_production
username
:
sample_app
password
:
<%= ENV['SAMPLE_APP_DATABASE_PASSWORD'] %>
config/environments/development.rb
View file @
4d61c3cc
...
@@ -73,4 +73,8 @@ Rails.application.configure do
...
@@ -73,4 +73,8 @@ Rails.application.configure do
# Uncomment if you wish to allow Action Cable access from any origin.
# Uncomment if you wish to allow Action Cable access from any origin.
# config.action_cable.disable_request_forgery_protection = true
# config.action_cable.disable_request_forgery_protection = true
# Force all access to the app over SSL, use Strict-Transport-Security,
# and use secure cookies.
config
.
force_ssl
=
true
end
end
config/routes.rb
View file @
4d61c3cc
...
@@ -6,5 +6,5 @@ Rails.application.routes.draw do
...
@@ -6,5 +6,5 @@ Rails.application.routes.draw do
get
'/about'
,
to:
'static_pages#about'
get
'/about'
,
to:
'static_pages#about'
get
'/contact'
,
to:
'static_pages#contact'
get
'/contact'
,
to:
'static_pages#contact'
get
'/signup'
,
to:
'users#new'
get
'/signup'
,
to:
'users#new'
resources
:users
end
end
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