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 @@ -6,7 +6,6 @@ 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'
# Use sqlite3 as the database for Active Record
Expand Down
8 changes: 1 addition & 7 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 @@ -85,7 +80,7 @@ GEM
nio4r (2.0.0)
nokogiri (1.7.0.1)
mini_portile2 (~> 2.1.0)
puma (3.8.1)
puma (3.8.2)
rack (2.0.1)
rack-test (0.6.3)
rack (>= 1.0)
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.

21 changes: 0 additions & 21 deletions Prime.rb

This file was deleted.

41 changes: 0 additions & 41 deletions Uoc1so.rb

This file was deleted.

Binary file removed app/assets/images/rails.png
Binary file not shown.
3 changes: 0 additions & 3 deletions app/assets/javascripts/static_pages.coffee

This file was deleted.

21 changes: 0 additions & 21 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.

1 change: 0 additions & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception

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

This file was deleted.

8 changes: 0 additions & 8 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,2 @@
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
2 changes: 0 additions & 2 deletions app/helpers/static_pages_helper.rb

This file was deleted.

31 changes: 31 additions & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
class User < ApplicationRecord
validates :name, presence: true
validates :email, presence:true
validates :phone, presence:true
validates :date, presence:true
attr_accessor :test
#@test=false
#if (self.name && self.email &&self.phone && self.date)
# @test=true
#end
validate :check_phone
private
def check_phone
if (self.name && self.email &&self.phone && self.date)
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

validate :check_date
private
def check_date
if self.name && self.email && self.phone && self.date
if ((Time.now.year-date.year)<7 || (Time.now.year-date.year)>90)
self.errors.add :date, "So tuoi phai tu 7 den 90"
end
end
end
end
12 changes: 0 additions & 12 deletions app/views/layouts/_header.html.erb

This file was deleted.

8 changes: 2 additions & 6 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' %>
</head>

<body>
<%= render "layouts/header" %>
<div class="container">
<%= yield %>
</div>

<%= yield %>
</body>
</html>
20 changes: 0 additions & 20 deletions app/views/static_pages/help.html.erb

This file was deleted.

24 changes: 0 additions & 24 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 Blog1
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 = "blog1_#{Rails.env}"
# config.active_job.queue_name_prefix = "UserModel_#{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: '_blog1_session'
Rails.application.config.session_store :cookie_store, key: '_UserModel_session'
4 changes: 0 additions & 4 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,7 +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: 65d1c785ca1398b24cfb5f3a427d5e21531815993be4861a324b6400cdc52794c21fbf8f6fa072642ef141a3701a01b5b195678f82427d6d90fd356bf2c8c3b0
secret_key_base: 714f5878bd79645d0966f8d59fb038c38a597d0adce3674e60480593cb5a232e6deffbabce6960c375853f3fd830f5d512373d356a1450d0fb83c54968fc6066

test:
secret_key_base: 7eb6c64bd00349e4b9471e4de609c2137cb95911a80eb76ebd27818deb94e542bf68bb07fd8ae8e7657897e24716c2ce2a46cd3b59e30dff497a4963c77b753d
secret_key_base: 5b264fe356f61f13a021017ece335feb13a026d3feb6869dbbd7f518ab2772dc0a6376276326629bb59c53f2c6cf00bf4fb8fc630ec6f63bea4778bebbfb48d5

# 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.
12 changes: 12 additions & 0 deletions db/migrate/20170315152727_create_users.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class CreateUsers < ActiveRecord::Migration[5.0]
def change
create_table :users do |t|
t.string :name
t.string :email
t.string :phone
t.date :date

t.timestamps
end
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: 20170315152727) do

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

end
14 changes: 0 additions & 14 deletions test/controllers/static_pages_controller_test.rb

This file was deleted.

Loading