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
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ end

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.0.2'
gem 'bootstrap-sass','3.3.6'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use Puma as the app server
Expand Down
6 changes: 0 additions & 6 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,6 @@ GEM
minitest (~> 5.1)
tzinfo (~> 1.1)
arel (7.1.4)
autoprefixer-rails (6.7.7)
execjs
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)
Expand Down Expand Up @@ -159,7 +154,6 @@ PLATFORMS
ruby

DEPENDENCIES
bootstrap-sass (= 3.3.6)
byebug
coffee-rails (~> 4.2)
jbuilder (~> 2.5)
Expand Down
21 changes: 0 additions & 21 deletions LICENSE

This file was deleted.

3 changes: 0 additions & 3 deletions app/assets/javascripts/static_pages.coffee

This file was deleted.

2 changes: 0 additions & 2 deletions app/assets/stylesheets/custom.scss

This file was deleted.

3 changes: 0 additions & 3 deletions app/assets/stylesheets/static_pages.scss

This file was deleted.

7 changes: 0 additions & 7 deletions app/controllers/static_pages_controller.rb

This file was deleted.

10 changes: 0 additions & 10 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,2 @@
module ApplicationHelper

# Trả về title đầy của trên từng trang
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
2 changes: 0 additions & 2 deletions app/helpers/static_pages_helper.rb

This file was deleted.

16 changes: 16 additions & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class User < ApplicationRecord

validate :valid_phone
validate :valid_birthday

def valid_birthday
if( (Time.now.year-birthday.year)>90.years || (Time.now.year-birthday.year)<7.years )
errors.add :birhtday, "ngay sinh tu 7-90 nam truoc"
end
end
def valid_phone
if(phone.length != 10 || phone[0] !='0')
errors.add :phone, "invalid phone"
end
end
end
12 changes: 0 additions & 12 deletions app/views/layouts/_header.html.erb

This file was deleted.

4 changes: 0 additions & 4 deletions app/views/layouts/_shim.html.erb

This file was deleted.

18 changes: 7 additions & 11 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
<!DOCTYPE html>
<html>
<head>
<title><%= full_title yield :title %></title>
<title>UserModel</title>
<%= csrf_meta_tags %>
<%= stylesheet_link_tag "application", media: "all",
"data-turbolinks-track": "reload" %>
<%= javascript_include_tag "application", "data-turbolinks-track": "reload" %>

<%render"layouts/shim" %>

<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
</head>

<body>
<%= render "layouts/header" %>
<div class="container">
<%= yield %>
</div>
<%= yield %>
</body>
</html>
</html>
14 changes: 0 additions & 14 deletions app/views/static_pages/help.html.erb

This file was deleted.

14 changes: 0 additions & 14 deletions app/views/static_pages/home.html.erb

This file was deleted.

2 changes: 1 addition & 1 deletion config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)

module StaticPage
module UserModel
class Application < Rails::Application
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
Expand Down
2 changes: 1 addition & 1 deletion config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@

# Use a real queuing backend for Active Job (and separate queues per environment)
# config.active_job.queue_adapter = :resque
# config.active_job.queue_name_prefix = "static_page_#{Rails.env}"
# config.active_job.queue_name_prefix = "user_model_#{Rails.env}"
config.action_mailer.perform_caching = false

# Ignore bad email addresses and do not raise email delivery errors.
Expand Down
2 changes: 1 addition & 1 deletion config/initializers/session_store.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Be sure to restart your server when you modify this file.

Rails.application.config.session_store :cookie_store, key: '_static_page_session'
Rails.application.config.session_store :cookie_store, key: '_user_model_session'
5 changes: 0 additions & 5 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
Rails.application.routes.draw do
get 'static_pages/home'

get 'static_pages/help'
root 'static_pages#home'

# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
end
4 changes: 2 additions & 2 deletions config/secrets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
# if you're sharing your code publicly.

development:
secret_key_base: ecf1db897dc42268291525ae53e00cd88a56f26660a2cb7f23b8e45b7a0ee8f6f167aa62216ff98f96ae9d0a21f35ad1242334f1f0ee88efc29aec9d7e030552
secret_key_base: a8d3c7c71a7a826d58b9110e05d74fb8c8a1a8a2cdd8361c9048e1c4c3505783af9ca9fa087f7e171549ced2e31b1c428a9bb22aa07d9436509d0dde95a5cbf4

test:
secret_key_base: 49ca599f7b2a21b5f2dc5d895a790331b9c0b14590830b470efef95ed08a2ae1ba526ad7944757588a9d28007583adfcc8e90a29e3e73be5550d16dd1e346e5b
secret_key_base: 112df00c5b4f89192fcfd1dab43465af8b2efd2cac21ad338a8beb1e237a916bafea36660bd0fba0a04618ccc54a4764b464f44994558aa66ef5bfbc49f169e7

# Do not keep production secrets in the repository,
# instead read values from the environment.
Expand Down
Binary file modified db/development.sqlite3
Binary file not shown.
9 changes: 9 additions & 0 deletions db/migrate/20170316020332_create_users.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class CreateUsers < ActiveRecord::Migration[5.0]
def change
create_table :users do |t|
t.string :name
t.string :email
t.timestamps
end
end
end
6 changes: 6 additions & 0 deletions db/migrate/20170316100207_add_details_to_users.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class AddDetailsToUsers < ActiveRecord::Migration[5.0]
def change
add_column :users, :birthday, :date
add_column :users, :phone, :string
end
end
24 changes: 24 additions & 0 deletions db/schema.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative source for your
# database schema. If you need to create the application database on another
# system, you should be using db:schema:load, not running all the migrations
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
# you'll amass, the slower it'll run and the greater likelihood for issues).
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20170316100207) do

create_table "users", force: :cascade do |t|
t.string "name"
t.string "email"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.date "birthday"
t.string "phone"
end

end
Binary file added db/test.sqlite3
Binary file not shown.
Loading