...
 
Commits (3)
......@@ -23,7 +23,7 @@ gem "htmlbeautifier"
group :development, :test do
gem 'sqlite3', '1.3.13'
gem 'byebug', '9.0.6', platform: :mri
gem 'byebug'
end
group :development do
......
......@@ -53,7 +53,7 @@ GEM
autoprefixer-rails (>= 5.2.1)
sass (>= 3.3.4)
builder (3.2.3)
byebug (9.0.6)
byebug (11.0.1)
codeclimate-engine-rb (0.4.1)
virtus (~> 1.0)
coderay (1.1.2)
......@@ -133,7 +133,7 @@ GEM
multi_json (1.13.1)
nenv (0.3.0)
nio4r (2.4.0)
nokogiri (1.10.3)
nokogiri (1.10.4)
mini_portile2 (~> 2.4.0)
notiffany (0.1.3)
nenv (~> 0.1)
......@@ -169,7 +169,7 @@ GEM
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.1.0)
rails-html-sanitizer (1.2.0)
loofah (~> 2.2, >= 2.2.2)
railties (5.1.6)
actionpack (= 5.1.6)
......@@ -257,7 +257,7 @@ PLATFORMS
DEPENDENCIES
bcrypt (= 3.1.12)
bootstrap-sass (= 3.3.7)
byebug (= 9.0.6)
byebug
coffee-rails (= 4.2.2)
debase
debride
......
web: bundle exec puma -C config/puma.rb
\ No newline at end of file
......@@ -15,81 +15,183 @@ textarea {
.center {
text-align: center;
h1{
h1 {
margin-bottom: 10px;
}
}
/* typography */
h1, h2, h3, h4, h5, h6 {
line-height: 1;
h1,
h2,
h3,
h4,
h5,
h6 {
line-height: 1;
}
h1 {
font-size: 3em;
letter-spacing: -2px;
margin-bottom: 30px;
text-align: center;
font-size: 3em;
letter-spacing: -2px;
margin-bottom: 30px;
text-align: center;
}
h2 {
font-size: 1.2em;
letter-spacing: -1px;
margin-bottom: 30px;
text-align: center;
font-weight: normal;
color: $gray-light;
font-size: 1.2em;
letter-spacing: -1px;
margin-bottom: 30px;
text-align: center;
font-weight: normal;
color: $gray-light;
}
p {
font-size: 1.1em;
line-height: 1.7em;
font-size: 1.1em;
line-height: 1.7em;
}
// header
#logo {
float :left;
float: left;
margin-right: 10px;
font-size:1.7em;
color:#fff;
font-size: 1.7em;
color: #fff;
text-transform: uppercase;
letter-spacing: -1px;
padding-top: 9px;
font-weight: bold;
&:hover{
&:hover {
color: #fff;
text-decoration: none;
}
}
img {
display:none;
}
// img {
// display:none;
// }
// footer
footer{
footer {
margin-top: 45px;
padding-top: 5px;
border-top: 1px solid;
color: $gray-light;
a{
a {
color: $gray;
&:hover{
&:hover {
color: $gray-darker;
}
}
small{
float:left;
small {
float: left;
}
ul{
ul {
float: right;
list-style: none;
li {
float: left;
margin-left: 15px;
}
}
}
@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: 20pix;
&: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 {
@extend .has-error;
.form-control {
color: $state-danger-text;
}
}
\ No newline at end of file
# frozen_string_literal: true
class UsersController < ApplicationController
def show
@user = User.find(params[:id])
end
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
else
render 'new'
end
end
private
def user_params
params.require(:user).permit(:name, :email, :password,
:password_confirmation)
end
end
# frozen_string_literal: true
module UsersHelper
def gravatar_for(user, size: 80)
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
<!DOCTYPE html>
<html>
<head>
<title><%= full_title(yield(:title)) %></title>
<%=render "layouts/rails_default"%>
<%=render "layouts/shim"%>
</head>
<body>
<%= render "layouts/header"%>
<div class="container">
<%= yield %>
<%= render "layouts/footer"%>
</div>
</body>
</html>
<head>
<title><%= full_title(yield(:title)) %></title>
<%=render "layouts/rails_default"%>
<%=render "layouts/shim"%>
</head>
<body>
<%= render "layouts/header"%>
<div class="container">
<% flash.each do |message_type, message|%>
<%= content_tag :div, message, class:"alert alert-#{message_type}" %>
<%end%>
<%= yield %>
<%= render "layouts/footer"%>
<%= debug(params) if Rails.env.development?%>
</div>
</body>
</html>
\ No newline at end of file
<% if @user.errors.any?%>
<div id="error_explanation">
<div class="alert alert-danger">
Ther form contains <%= pluralize(@user.errors.count, "error")%>
</div>
<ul>
<% @user.errors.full_messages.each do |msg|%>
<li><%=msg%></li>
<% end%>
</ul>
</div>
<% end %>
......@@ -3,4 +3,4 @@
<p>
Contact the Ruby on Rails Tutorial about the sample app at the
<a href="https://railstutorial.jp/contact">contact page</a>.
</p>
\ No newline at end of file
</p>
<% provide(:title, "Sign Up")%>
<% provide(:title,"Sign up")%>
<h1>Sign up</h1>
<p>This will be a signup page for new users.</p>
<div class="row">
<div>
<%=form_for(@user, url: signup_path) 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>
\ No newline at end of file
<% 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>
# frozen_string_literal: true
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
......@@ -45,14 +47,14 @@ Rails.application.configure do
# config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ]
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
# config.force_ssl = true
config.force_ssl = true
# Use the lowest log level to ensure availability of diagnostic information
# when problems arise.
config.log_level = :debug
# Prepend all log lines with the following tags.
config.log_tags = [ :request_id ]
config.log_tags = [:request_id]
# Use a different cache store in production.
# config.cache_store = :mem_cache_store
......@@ -80,7 +82,7 @@ Rails.application.configure do
# require 'syslog/logger'
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
if ENV["RAILS_LOG_TO_STDOUT"].present?
if ENV['RAILS_LOG_TO_STDOUT'].present?
logger = ActiveSupport::Logger.new(STDOUT)
logger.formatter = config.log_formatter
config.logger = ActiveSupport::TaggedLogging.new(logger)
......
# frozen_string_literal: true
Rails.application.routes.draw do
root 'static_pages#home'
get "/help", to:"static_pages#help"
get "/about", to:"static_pages#about"
get "/contact", to:"static_pages#contact"
get "/signup", to:"users#new"
get '/help', to: 'static_pages#help'
get '/about', to: 'static_pages#about'
get '/contact', to: 'static_pages#contact'
get '/signup', to: 'users#new'
post '/signup', to: 'users#create'
resources :users
end
# frozen_string_literal: true
require 'test_helper'
class SiteLayoutTest < ActionDispatch::IntegrationTest
test "layout links" do
test 'layout links' do
get root_path
assert_template "static_pages/home"
assert_select "a[href=?]", root_path,count:2
assert_select "a[href=?]", help_path
assert_select "a[href=?]", about_path
assert_select "a[href=?]", contact_path
assert_template 'static_pages/home'
assert_select 'a[href=?]', root_path, count: 2
assert_select 'a[href=?]', help_path
assert_select 'a[href=?]', about_path
assert_select 'a[href=?]', contact_path
get contact_path
assert_select "title",full_title("Contact")
assert_select 'title', full_title('Contact')
get signup_path
assert_select "title",full_title("Sign Up")
assert_select 'title', full_title('Sign up')
end
end
# frozen_string_literal: true
require 'test_helper'
class UsersSignupTest < ActionDispatch::IntegrationTest
test 'invalid signup information' do
get signup_path
assert_no_difference 'User.count' do
post users_path, params: { user: { name: '',
email: '[email protected]',
password: 'foo',
password_confirmation: 'bar' } }
end
assert_template 'users/new'
assert_select 'div#error_explanation'
assert_select 'div.field_with_errors'
assert_select 'ul' do
assert_select 'li', 'Name can\'t be blank'
assert_select 'li', 'Email is invalid'
assert_select 'li', 'Password confirmation doesn\'t match Password'
assert_select 'li', 'Password is too short (minimum is 6 characters)'
end
assert_select 'form[action="/signup"]'
end
test 'valid signup information' do
get signup_path
assert_difference 'User.count', 1 do
post users_path, params: { user: { name: 'Example User',
email: '[email protected]',
password: 'password',
password_confirmation: 'password' } }
end
follow_redirect!
assert_template 'users/show'
assert_not flash.blank?
end
end
This source diff could not be displayed because it is too large. You can view the blob instead.