diff --git a/Gemfile b/Gemfile
index b5fbf94..5184aae 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,53 +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"
+gem "sqlite3"
+gem "puma", "~> 3.0"
+gem "sass-rails", "~> 5.0"
+gem "uglifier", ">= 1.3.0"
+gem "coffee-rails", "~> 4.2"
-# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
-gem 'rails', '~> 5.0.2'
-# Use sqlite3 as the database for Active Record
-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 "bootstrap-sass", "3.3.6"
+gem "bcrypt", "3.1.11"
-# 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 "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]
diff --git a/Gemfile.lock b/Gemfile.lock
index 5a8cef1..6624620 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -39,6 +39,12 @@ GEM
minitest (~> 5.1)
tzinfo (~> 1.1)
arel (7.1.4)
+ autoprefixer-rails (6.7.7)
+ execjs
+ bcrypt (3.1.11)
+ bootstrap-sass (3.3.6)
+ autoprefixer-rails (>= 5.2.1)
+ sass (>= 3.3.4)
builder (3.2.3)
byebug (9.0.6)
coffee-rails (4.2.1)
@@ -154,6 +160,8 @@ PLATFORMS
ruby
DEPENDENCIES
+ bcrypt (= 3.1.11)
+ bootstrap-sass (= 3.3.6)
byebug
coffee-rails (~> 4.2)
jbuilder (~> 2.5)
diff --git a/app/assets/images/rails.png b/app/assets/images/rails.png
new file mode 100644
index 0000000..f9fa0a0
Binary files /dev/null and b/app/assets/images/rails.png differ
diff --git a/app/assets/stylesheets/custom.scss b/app/assets/stylesheets/custom.scss
new file mode 100644
index 0000000..5df53db
--- /dev/null
+++ b/app/assets/stylesheets/custom.scss
@@ -0,0 +1,87 @@
+@import "bootstrap-sprockets";
+@import "bootstrap";
+
+$gray-medium-light: #eaeaea;
+
+body {
+ padding-top: 60px;
+}
+
+section {
+ overflow: auto;
+}
+
+textarea {
+ resize: vertical;
+}
+
+.center {
+ text-align: center;
+ h1 {
+ margin-bottom: 10px;
+ }
+}
+
+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;
+}
+
+#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 {
+ 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;
+ }
+ }
+}
diff --git a/app/controllers/static_pages_controller.rb b/app/controllers/static_pages_controller.rb
new file mode 100644
index 0000000..d304760
--- /dev/null
+++ b/app/controllers/static_pages_controller.rb
@@ -0,0 +1,13 @@
+class StaticPagesController < ApplicationController
+ def home
+ end
+
+ def help
+ end
+
+ def about
+ end
+
+ def contact
+ end
+end
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index c0f8a5c..2ec9ecc 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -1,78 +1,4 @@
class UsersController < ApplicationController
- before_action :set_user, only: [:show, :edit, :update, :destroy]
-
- include UsersHelper
- # GET /users
- # GET /users.json
- def index
- # byebug la 1 gem cua ruby giup debug
- @users = User.all
- @p_hust = print_hust
- end
-
- # GET /users/1
- # GET /users/1.json
- def show
- end
-
- # GET /users/new
def new
- @user = User.new
- end
-
- # GET /users/1/edit
- def edit
- end
-
- # POST /users
- # POST /users.json
- def create
- @user = User.new(user_params)
-
-
- respond_to do |format|
- if @user.save
- format.html { redirect_to @user, notice: 'User was successfully created.' }
- format.json { render :show, status: :created, location: @user }
- else
- format.html { render :new }
- format.json { render json: @user.errors, status: :unprocessable_entity }
- end
- end
- end
-
- # PATCH/PUT /users/1
- # PATCH/PUT /users/1.json
- def update
- respond_to do |format|
- if @user.update(user_params)
- format.html { redirect_to @user, notice: 'User was successfully updated.' }
- format.json { render :show, status: :ok, location: @user }
- else
- format.html { render :edit }
- format.json { render json: @user.errors, status: :unprocessable_entity }
- end
- end
- end
-
- # DELETE /users/1
- # DELETE /users/1.json
- def destroy
- @user.destroy
- respond_to do |format|
- format.html { redirect_to users_url, notice: 'User was successfully destroyed.' }
- format.json { head :no_content }
- end
end
-
- private
- # Use callbacks to share common setup or constraints between actions.
- def set_user
- @user = User.find(params[:id])
- end
-
- # Never trust parameters from the scary internet, only allow the white list through.
- def user_params
- params.require(:user).permit(:name, :email)
- end
end
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index de6be79..6c3b28e 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -1,2 +1,10 @@
module ApplicationHelper
-end
+ 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
\ No newline at end of file
diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb
index 3a4291d..2310a24 100644
--- a/app/helpers/users_helper.rb
+++ b/app/helpers/users_helper.rb
@@ -1,6 +1,2 @@
module UsersHelper
- def print_hust
- "Hello Lam Beo Bui"
- end
-
end
diff --git a/app/models/user.rb b/app/models/user.rb
index 379658a..e8d10b3 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -1,2 +1,10 @@
class User < ApplicationRecord
+ before_save{email.downcase!}
+ validates :name, presence: true, length: {maximum: 50}
+ VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
+ validates :email, presence: true, length: {maximum: 255},
+ format: {with: VALID_EMAIL_REGEX},
+ uniqueness: {case_sensitive: false}
+ has_secure_password
+ validates :password, presence: true, length: {minimum: 5}
end
diff --git a/app/views/layouts/_footer.html.erb b/app/views/layouts/_footer.html.erb
new file mode 100644
index 0000000..dca4384
--- /dev/null
+++ b/app/views/layouts/_footer.html.erb
@@ -0,0 +1,13 @@
+
\ No newline at end of file
diff --git a/app/views/layouts/_header.html.erb b/app/views/layouts/_header.html.erb
new file mode 100644
index 0000000..5def461
--- /dev/null
+++ b/app/views/layouts/_header.html.erb
@@ -0,0 +1,12 @@
+