Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
*.gem
*.rbc
/.config
/config/secrets.yml
/config/database.yml
/log/
/coverage/
/InstalledFiles
/pkg/
Expand Down
58 changes: 18 additions & 40 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,55 +1,33 @@
source 'https://rubygems.org'
source "https://rubygems.org"

git_source(:github) do |repo_name|
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
"https://github.com/#{repo_name}.git"
end

gem "rails", "~> 5.0.2"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

xóa dòng này em nhé

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.0.2'
# Use sqlite3 as the database for Active Record
gem 'bcrypt', '3.1.7'
#
gem 'sqlite3'
# Use Puma as the app server
gem 'puma', '~> 3.0'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
gem "bcrypt", "3.1.7"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

xóa dòng nhé

# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 3.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
gem "bootstrap-sass","3.3.7"
gem "sqlite3"
gem "puma", "~> 3.0"
gem "sass-rails", "~> 5.0"
gem "uglifier", ">= 1.3.0"
gem "coffee-rails", "~> 4.2"
gem "jquery-rails"
gem "turbolinks", "~> 5"
gem "jbuilder", "~> 2.5"

group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platform: :mri
gem "byebug", platform: :mri
end

group :development do
# Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
gem 'web-console', '>= 3.3.0'
gem 'listen', '~> 3.0.5'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
gem "web-console", ">= 3.3.0"
gem "listen", "~> 3.0.5"
gem "spring"
gem "spring-watcher-listen", "~> 2.0.0"
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
gem "tzinfo-data", platforms: [:mingw, :mswin, :x64_mingw, :jruby]
6 changes: 6 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,12 @@ GEM
minitest (~> 5.1)
tzinfo (~> 1.1)
arel (7.1.4)
autoprefixer-rails (6.7.7)
execjs
bcrypt (3.1.7)
bootstrap-sass (3.3.7)
autoprefixer-rails (>= 5.2.1)
sass (>= 3.3.4)
builder (3.2.3)
byebug (9.0.6)
coffee-rails (4.2.1)
Expand Down Expand Up @@ -156,6 +161,7 @@ PLATFORMS

DEPENDENCIES
bcrypt (= 3.1.7)
bootstrap-sass (= 3.3.7)
byebug
coffee-rails (~> 4.2)
jbuilder (~> 2.5)
Expand Down
Binary file added app/assets/images/rails.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
181 changes: 181 additions & 0 deletions app/assets/stylesheets/custom.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
@import "bootstrap-sprockets";
@import "bootstrap";

/* mixins, variables, etc. */

$gray-medium-light: #eaeaea;

@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;
}

/* universal */

body {
padding-top: 60px;
}

section {
overflow: auto;
}

textarea {
resize: vertical;
}

.center {
text-align: center;
h1 {
margin-bottom: 10px;
}
}

/* typography */

h1, h2, h3, h4, h5, h6 {
line-height: 1;
}

h1 {
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;
}

p {
font-size: 1.1em;
line-height: 1.7em;
}

/* header */

#logo
{
float: left;
margin-right: 10px;
font-size: 1.7em;
color: white;
text-transform: uppercase;
letter-spacing: -1px;
padding-top: 9px;
font-weight: bold;
&:hover {
color: white;
text-decoration: none;
}
}

/* footer */

footer
{
margin-top: 45px;
padding-top: 5px;
border-top: 1px solid $gray-medium-light;
color: $gray-light;
a {
color: $gray;
&:hover {
color: $gray-darker;
}
}
small {
float: left;
}
ul {
float: right;
list-style: none;
li {
float: left;
margin-left: 15px;
}
}
}

/* 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 {
@extend .has-error;
.form-control {
color: $state-danger-text;
}
}
13 changes: 13 additions & 0 deletions app/controllers/static_pages_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class StaticPagesController < ApplicationController
def home
end

def help
end

def about
end

def sign_up
end
end
26 changes: 26 additions & 0 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
class UsersController < ApplicationController
def new
@user = User.new
end

def show
@user = User.find params[:id]
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, :phonenumber, :birthday,
:password, :password_confirmation
end
end
8 changes: 8 additions & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,10 @@
module ApplicationHelper
def full_title page_title = ""
base_title = "Ruby on Rails Tutorial Sample App"
if page_title.empty?
base_title
else
page_title + " | " + base_title
end
end
end
7 changes: 7 additions & 0 deletions app/helpers/users_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
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
4 changes: 2 additions & 2 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class User < ApplicationRecord
private

def check_phonenumber
if self.phonenumber && self.phonenumber[0] != '0'
if self.phonenumber && self.phonenumber[0] != "0"
self.errors.add :phonenumber,"Must begin with 0"
end
if self.phonenumber && self.phonenumber.length != 10
Expand All @@ -26,7 +26,7 @@ def check_phonenumber
def check_birthday
if self.birthday &&
(self.birthday.year < Time.now.year - 90 ||
self.birthday.year > Time.now.year -7)
self.birthday.year > Time.now.year - 7)
self.errors.add :birthday, "Year must from 90 years ago to 7 years ago"
end
end
Expand Down
13 changes: 13 additions & 0 deletions app/views/layouts/_footer.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<footer class="footer">
<small>
The <a href="http://www.railstutorial.org/">Ruby on Rails Tutorial</a>
by <a href="http://www.michaelhartl.com/">Michael Hartl</a>
</small>
<nav>
<ul>
<li><%= link_to "About", static_pages_about_path %></li>
<li><%= link_to "Contact", '#' %></li>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use double quote " " in Rails

<li><a href="http://news.railstutorial.org/">News</a></li>
</ul>
</nav>
</footer>
12 changes: 12 additions & 0 deletions app/views/layouts/_header.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<header class="navbar navbar-fixed-top navbar-inverse">
<div class="container">
<%= link_to "Sample App", "#", id: "logo" %>
<nav>
<ul class="nav navbar-nav navbar-right">
<li><%= link_to "Home", static_pages_home_path %></li>
<li><%= link_to "Help", static_pages_help_path %></li>
<li><%= link_to "Log in", "#" %></li>
</ul>
</nav>
</div>
</header>
3 changes: 3 additions & 0 deletions app/views/layouts/_rails_default.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<%= csrf_meta_tags %>
<%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track": "reload" %>
<%= javascript_include_tag "application", "data-turbolinks-track": "reload" %>
Loading