Use SSL and the Puma webserver in production

parent 188a6c3f
Pipeline #1266 failed with stages
in 0 seconds
@import "bootstrap"; @import "bootstrap";
.center { .center {
text-align: center; text-align: center;
} h1 {
.center h1 {
margin-bottom: 10px; 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;
}
}
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
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
...@@ -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
<% 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
<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>
<% 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
...@@ -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'] %>
...@@ -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
...@@ -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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment