diff --git a/Gemfile b/Gemfile
index b60bc08..e380459 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,4 +1,4 @@
-source 'https://rubygems.org'
+source "https://rubygems.org"
git_source(:github) do |repo_name|
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
@@ -6,49 +6,49 @@ git_source(:github) do |repo_name|
end
-gem 'bootstrap-sass','3.3.6'
-# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
-gem 'rails', '~> 5.0.2'
+gem "bootstrap-sass","3.3.6"
+# Bundle edge Rails instead: gem "rails", github: "rails/rails"
+gem "rails", "~> 5.0.2"
# Use sqlite3 as the database for Active Record
-gem 'sqlite3'
+gem "sqlite3"
# Use Puma as the app server
-gem 'puma', '~> 3.0'
+gem "puma", "~> 3.0"
# Use SCSS for stylesheets
-gem 'sass-rails', '~> 5.0'
+gem "sass-rails", "~> 5.0"
# Use Uglifier as compressor for JavaScript assets
-gem 'uglifier', '>= 1.3.0'
+gem "uglifier", ">= 1.3.0"
# Use CoffeeScript for .coffee assets and views
-gem 'coffee-rails', '~> 4.2'
+gem "coffee-rails", "~> 4.2"
# See https://github.com/rails/execjs#readme for more supported runtimes
-# gem 'therubyracer', platforms: :ruby
+# gem "therubyracer", platforms: :ruby
# Use jquery as the JavaScript library
-gem 'jquery-rails'
+gem "jquery-rails"
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
-gem 'turbolinks', '~> 5'
+gem "turbolinks", "~> 5"
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
-gem 'jbuilder', '~> 2.5'
+gem "jbuilder", "~> 2.5"
# Use Redis adapter to run Action Cable in production
-# gem 'redis', '~> 3.0'
+# gem "redis", "~> 3.0"
# Use ActiveModel has_secure_password
-# gem 'bcrypt', '~> 3.1.7'
+gem "bcrypt", "~> 3.1.7"
# Use Capistrano for deployment
-# gem 'capistrano-rails', group: :development
+# gem "capistrano-rails", group: :development
group :development, :test do
- # Call 'byebug' anywhere in the code to stop execution and get a debugger console
- gem 'byebug', platform: :mri
+ # Call "byebug" anywhere in the code to stop execution and get a debugger console
+ 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'
+ 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 "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 fba81e1..72de66e 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -41,6 +41,7 @@ GEM
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)
@@ -159,6 +160,7 @@ PLATFORMS
ruby
DEPENDENCIES
+ bcrypt (~> 3.1.7)
bootstrap-sass (= 3.3.6)
byebug
coffee-rails (~> 4.2)
diff --git a/LICENSE b/LICENSE
deleted file mode 100644
index 5b33d60..0000000
--- a/LICENSE
+++ /dev/null
@@ -1,21 +0,0 @@
-MIT License
-
-Copyright (c) 2017 TrungNT
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
diff --git a/Rakefile b/Rakefile
deleted file mode 100644
index e85f913..0000000
--- a/Rakefile
+++ /dev/null
@@ -1,6 +0,0 @@
-# Add your own tasks in files placed in lib/tasks ending in .rake,
-# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
-
-require_relative 'config/application'
-
-Rails.application.load_tasks
diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js
deleted file mode 100644
index b12018d..0000000
--- a/app/assets/javascripts/application.js
+++ /dev/null
@@ -1,16 +0,0 @@
-// This is a manifest file that'll be compiled into application.js, which will include all the files
-// listed below.
-//
-// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
-// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
-//
-// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
-// compiled file. JavaScript code in this file should be added after the last require_* statement.
-//
-// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
-// about supported directives.
-//
-//= require jquery
-//= require jquery_ujs
-//= require turbolinks
-//= require_tree .
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
new file mode 100644
index 0000000..2ec9ecc
--- /dev/null
+++ b/app/controllers/users_controller.rb
@@ -0,0 +1,4 @@
+class UsersController < ApplicationController
+ def new
+ end
+end
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 17c5ab5..a44252d 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -1,10 +1,10 @@
module ApplicationHelper
- def full_title page_title=''
- base_title="Ruby on Rails Tutorial Sample App"
+ def full_title page_title = ""
+ base_title = "Ruby on Rails Tutorial Sample App"
if page_title.empty?
base_title
else
- page_title+ "|" +base_title
+ page_title + "|" + base_title
end
end
end
diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb
index 286b223..3c34c81 100644
--- a/app/mailers/application_mailer.rb
+++ b/app/mailers/application_mailer.rb
@@ -1,4 +1,4 @@
class ApplicationMailer < ActionMailer::Base
- default from: 'from@example.com'
- layout 'mailer'
+ default from: "from@example.com"
+ layout "mailer"
end
diff --git a/app/models/user.rb b/app/models/user.rb
new file mode 100644
index 0000000..f9bed4f
--- /dev/null
+++ b/app/models/user.rb
@@ -0,0 +1,27 @@
+class User < ApplicationRecord
+ validates :name, presence: true
+ validates :email, presence:true
+ validates :phone, presence:true
+ validates :birthday, presence:true
+ validate :check_phone
+ validate :check_date
+ has_secure_password
+
+ private
+ def check_phone
+ if self.phone
+ if self.phone.length == 10 && self.phone[0] == "0"
+ else
+ self.errors.add :phone, "So dien thoai phai co 10 ky tu va khong bat dau boi 0"
+ end
+ end
+ end
+
+ def check_date
+ if self.birthday
+ if (Time.now.year-birthday.year) < 7 || (Time.now.year-birthday.year) > 90
+ self.errors.add :date, "So tuoi phai tu 7 den 90"
+ end
+ end
+ end
+end
diff --git a/app/views/layouts/_header.html.erb b/app/views/layouts/_header.html.erb
index 4554fd6..a77b138 100644
--- a/app/views/layouts/_header.html.erb
+++ b/app/views/layouts/_header.html.erb
@@ -1,12 +1,12 @@