Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
venjobs_app
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Quang Vinh Nguyen
venjobs_app
Commits
f87141f5
Commit
f87141f5
authored
Jun 25, 2018
by
Quang Vinh Nguyen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add random password
parent
13c666b9
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
128 additions
and
120 deletions
+128
-120
app/controllers/entries_controller.rb
+11
-5
app/models/user.rb
+5
-4
db/schema.rb
+112
-111
No files found.
app/controllers/entries_controller.rb
View file @
f87141f5
...
@@ -26,14 +26,20 @@ class EntriesController < ApplicationController
...
@@ -26,14 +26,20 @@ class EntriesController < ApplicationController
@entry
=
Entry
.
new
(
entry_params
)
@entry
=
Entry
.
new
(
entry_params
)
@job
=
Job
.
find
(
params
[
:job_id
])
@job
=
Job
.
find
(
params
[
:job_id
])
random_password
=
Devise
.
friendly_token
@user
=
User
.
find_by
(
email:
params
[
:entry
][
:entry_email
])
||
if
@user
=
User
.
find_by
(
email:
params
[
:entry
][
:entry_email
])
User
.
create
(
name:
params
[
:entry
][
:entry_name
],
else
@user
=
User
.
new
(
name:
params
[
:entry
][
:entry_name
],
email:
params
[
:entry
][
:entry_email
],
email:
params
[
:entry
][
:entry_email
],
phone:
params
[
:entry
][
:entry_phone
],
phone:
params
[
:entry
][
:entry_phone
],
address:
params
[
:entry
][
:entry_address
])
#,
address:
params
[
:entry
][
:entry_address
],
# password: 'password',
password:
random_password
,
# password_confirmation: 'password')
password_confirmation:
random_password
)
@user
.
skip_confirmation!
@user
.
save!
end
@entry
.
user_id
=
@user
.
id
@entry
.
user_id
=
@user
.
id
@entry
.
job_id
=
@job
.
id
@entry
.
job_id
=
@job
.
id
...
...
app/models/user.rb
View file @
f87141f5
...
@@ -4,8 +4,8 @@ class User < ApplicationRecord
...
@@ -4,8 +4,8 @@ class User < ApplicationRecord
# Include default devise modules. Others available are:
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
# :confirmable, :lockable, :timeoutable and :omniauthable
devise
:database_authenticatable
,
:registerable
,
devise
:database_authenticatable
,
:registerable
,
:recoverable
,
:rememberable
,
:validatable
#
,
:recoverable
,
:rememberable
,
:validatable
,
#
:confirmable
:confirmable
has_many
:favorite_jobs
,
dependent: :destroy
has_many
:favorite_jobs
,
dependent: :destroy
...
@@ -13,7 +13,7 @@ class User < ApplicationRecord
...
@@ -13,7 +13,7 @@ class User < ApplicationRecord
dependent: :destroy
dependent: :destroy
has_many
:jobs
,
through: :entries
has_many
:jobs
,
through: :entries
validates
:name
,
presence:
true
,
length:
{
maximum:
255
}
#
validates :name, presence: true, length: { maximum: 255 }
# validates :prefix, presence: true
# validates :prefix, presence: true
...
@@ -27,8 +27,9 @@ class User < ApplicationRecord
...
@@ -27,8 +27,9 @@ class User < ApplicationRecord
validates
:password
,
presence:
true
,
length:
{
minimum:
8
}
validates
:password
,
presence:
true
,
length:
{
minimum:
8
}
# Sends a
ctivation
email.
# Sends a
pply
email.
def
send_job_apply_email
(
job
)
def
send_job_apply_email
(
job
)
UserMailer
.
job_apply
(
self
,
job
).
deliver_now
UserMailer
.
job_apply
(
self
,
job
).
deliver_now
end
end
end
end
db/schema.rb
View file @
f87141f5
# frozen_string_literal: true
# This file is auto-generated from the current state of the database. Instead
# 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
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
# incrementally modify your database, and then regenerate this schema definition.
...
@@ -10,133 +12,132 @@
...
@@ -10,133 +12,132 @@
#
#
# It's strongly recommended that you check this file into your version control system.
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
2018_06_19_011959
)
do
ActiveRecord
::
Schema
.
define
(
version:
20_180_619_011_959
)
do
create_table
'cities'
,
options:
'ENGINE=InnoDB DEFAULT CHARSET=utf8'
,
force: :cascade
do
|
t
|
create_table
"cities"
,
options:
"ENGINE=InnoDB DEFAULT CHARSET=utf8"
,
force: :cascade
do
|
t
|
t
.
string
'name'
t
.
string
"name"
t
.
string
'city_type'
t
.
string
"city_type"
t
.
string
'slug'
t
.
string
"slug"
t
.
string
'name_with_type'
t
.
string
"name_with_type"
t
.
string
'path'
t
.
string
"path"
t
.
integer
'code'
t
.
integer
"code"
t
.
integer
'parent_code'
t
.
integer
"parent_code"
t
.
datetime
'created_at'
,
null:
false
t
.
datetime
"created_at"
,
null:
false
t
.
datetime
'updated_at'
,
null:
false
t
.
datetime
"updated_at"
,
null:
false
t
.
index
%w[name slug]
,
name:
'index_cities_on_name_and_slug'
t
.
index
[
"name"
,
"slug"
],
name:
"index_cities_on_name_and_slug"
end
end
create_table
"cities_jobs"
,
options:
"ENGINE=InnoDB DEFAULT CHARSET=utf8"
,
force: :cascade
do
|
t
|
create_table
'cities_jobs'
,
options:
'ENGINE=InnoDB DEFAULT CHARSET=utf8'
,
force: :cascade
do
|
t
|
t
.
bigint
"job_id"
t
.
bigint
'job_id'
t
.
bigint
"city_id"
t
.
bigint
'city_id'
t
.
datetime
"created_at"
,
null:
false
t
.
datetime
'created_at'
,
null:
false
t
.
datetime
"updated_at"
,
null:
false
t
.
datetime
'updated_at'
,
null:
false
t
.
index
[
"city_id"
],
name:
"index_cities_jobs_on_city_id"
t
.
index
[
'city_id'
],
name:
'index_cities_jobs_on_city_id'
t
.
index
[
"job_id"
,
"city_id"
],
name:
"index_cities_jobs_on_job_id_and_city_id"
,
unique:
true
t
.
index
%w[job_id city_id]
,
name:
'index_cities_jobs_on_job_id_and_city_id'
,
unique:
true
t
.
index
[
"job_id"
],
name:
"index_cities_jobs_on_job_id"
t
.
index
[
'job_id'
],
name:
'index_cities_jobs_on_job_id'
end
end
create_table
"companies"
,
options:
"ENGINE=InnoDB DEFAULT CHARSET=utf8"
,
force: :cascade
do
|
t
|
create_table
'companies'
,
options:
'ENGINE=InnoDB DEFAULT CHARSET=utf8'
,
force: :cascade
do
|
t
|
t
.
string
"name"
t
.
string
'name'
t
.
text
"description"
t
.
text
'description'
t
.
string
"address"
t
.
string
'address'
t
.
string
"email"
t
.
string
'email'
t
.
string
"phone"
t
.
string
'phone'
t
.
string
"fax"
t
.
string
'fax'
t
.
string
"number_of_employees"
t
.
string
'number_of_employees'
t
.
datetime
"created_at"
,
null:
false
t
.
datetime
'created_at'
,
null:
false
t
.
datetime
"updated_at"
,
null:
false
t
.
datetime
'updated_at'
,
null:
false
end
end
create_table
"entries"
,
options:
"ENGINE=InnoDB DEFAULT CHARSET=utf8"
,
force: :cascade
do
|
t
|
create_table
'entries'
,
options:
'ENGINE=InnoDB DEFAULT CHARSET=utf8'
,
force: :cascade
do
|
t
|
t
.
bigint
"user_id"
t
.
bigint
'user_id'
t
.
bigint
"job_id"
t
.
bigint
'job_id'
t
.
string
"entry_name"
t
.
string
'entry_name'
t
.
string
"entry_email"
t
.
string
'entry_email'
t
.
string
"entry_phone"
t
.
string
'entry_phone'
t
.
text
"entry_address"
t
.
text
'entry_address'
t
.
datetime
"created_at"
,
null:
false
t
.
datetime
'created_at'
,
null:
false
t
.
datetime
"updated_at"
,
null:
false
t
.
datetime
'updated_at'
,
null:
false
t
.
index
[
"job_id"
],
name:
"index_entries_on_job_id"
t
.
index
[
'job_id'
],
name:
'index_entries_on_job_id'
t
.
index
[
"user_id"
,
"job_id"
],
name:
"index_entries_on_user_id_and_job_id"
,
unique:
true
t
.
index
%w[user_id job_id]
,
name:
'index_entries_on_user_id_and_job_id'
,
unique:
true
t
.
index
[
"user_id"
],
name:
"index_entries_on_user_id"
t
.
index
[
'user_id'
],
name:
'index_entries_on_user_id'
end
end
create_table
"favorite_jobs"
,
options:
"ENGINE=InnoDB DEFAULT CHARSET=utf8"
,
force: :cascade
do
|
t
|
create_table
'favorite_jobs'
,
options:
'ENGINE=InnoDB DEFAULT CHARSET=utf8'
,
force: :cascade
do
|
t
|
t
.
bigint
"user_id"
t
.
bigint
'user_id'
t
.
bigint
"job_id"
t
.
bigint
'job_id'
t
.
datetime
"created_at"
,
null:
false
t
.
datetime
'created_at'
,
null:
false
t
.
datetime
"updated_at"
,
null:
false
t
.
datetime
'updated_at'
,
null:
false
t
.
index
[
"job_id"
],
name:
"index_favorite_jobs_on_job_id"
t
.
index
[
'job_id'
],
name:
'index_favorite_jobs_on_job_id'
t
.
index
[
"user_id"
],
name:
"index_favorite_jobs_on_user_id"
t
.
index
[
'user_id'
],
name:
'index_favorite_jobs_on_user_id'
end
end
create_table
"industries"
,
options:
"ENGINE=InnoDB DEFAULT CHARSET=utf8"
,
force: :cascade
do
|
t
|
create_table
'industries'
,
options:
'ENGINE=InnoDB DEFAULT CHARSET=utf8'
,
force: :cascade
do
|
t
|
t
.
string
"code"
t
.
string
'code'
t
.
string
"name"
t
.
string
'name'
t
.
string
"slug"
t
.
string
'slug'
t
.
datetime
"created_at"
,
null:
false
t
.
datetime
'created_at'
,
null:
false
t
.
datetime
"updated_at"
,
null:
false
t
.
datetime
'updated_at'
,
null:
false
t
.
index
[
"name"
],
name:
"index_industries_on_name"
t
.
index
[
'name'
],
name:
'index_industries_on_name'
end
end
create_table
"industries_jobs"
,
options:
"ENGINE=InnoDB DEFAULT CHARSET=utf8"
,
force: :cascade
do
|
t
|
create_table
'industries_jobs'
,
options:
'ENGINE=InnoDB DEFAULT CHARSET=utf8'
,
force: :cascade
do
|
t
|
t
.
bigint
"job_id"
t
.
bigint
'job_id'
t
.
bigint
"industry_id"
t
.
bigint
'industry_id'
t
.
datetime
"created_at"
,
null:
false
t
.
datetime
'created_at'
,
null:
false
t
.
datetime
"updated_at"
,
null:
false
t
.
datetime
'updated_at'
,
null:
false
t
.
index
[
"industry_id"
],
name:
"index_industries_jobs_on_industry_id"
t
.
index
[
'industry_id'
],
name:
'index_industries_jobs_on_industry_id'
t
.
index
[
"job_id"
,
"industry_id"
],
name:
"index_industries_jobs_on_job_id_and_industry_id"
,
unique:
true
t
.
index
%w[job_id industry_id]
,
name:
'index_industries_jobs_on_job_id_and_industry_id'
,
unique:
true
t
.
index
[
"job_id"
],
name:
"index_industries_jobs_on_job_id"
t
.
index
[
'job_id'
],
name:
'index_industries_jobs_on_job_id'
end
end
create_table
"jobs"
,
options:
"ENGINE=InnoDB DEFAULT CHARSET=utf8"
,
force: :cascade
do
|
t
|
create_table
'jobs'
,
options:
'ENGINE=InnoDB DEFAULT CHARSET=utf8'
,
force: :cascade
do
|
t
|
t
.
string
"title"
t
.
string
'title'
t
.
bigint
"company_id"
t
.
bigint
'company_id'
t
.
string
"position"
t
.
string
'position'
t
.
decimal
"salary"
,
precision:
12
,
scale:
2
t
.
decimal
'salary'
,
precision:
12
,
scale:
2
t
.
datetime
"expiry_date"
t
.
datetime
'expiry_date'
t
.
text
"description"
t
.
text
'description'
t
.
datetime
"update_date"
t
.
datetime
'update_date'
t
.
boolean
"published"
t
.
boolean
'published'
t
.
text
"welfare"
t
.
text
'welfare'
t
.
text
"condition"
t
.
text
'condition'
t
.
text
"link"
t
.
text
'link'
t
.
datetime
"created_at"
,
null:
false
t
.
datetime
'created_at'
,
null:
false
t
.
datetime
"updated_at"
,
null:
false
t
.
datetime
'updated_at'
,
null:
false
t
.
index
[
"company_id"
],
name:
"index_jobs_on_company_id"
t
.
index
[
'company_id'
],
name:
'index_jobs_on_company_id'
t
.
index
[
"title"
,
"update_date"
],
name:
"index_jobs_on_title_and_update_date"
t
.
index
%w[title update_date]
,
name:
'index_jobs_on_title_and_update_date'
t
.
index
[
"title"
],
name:
"index_jobs_on_title"
t
.
index
[
'title'
],
name:
'index_jobs_on_title'
end
end
create_table
"users"
,
options:
"ENGINE=InnoDB DEFAULT CHARSET=utf8"
,
force: :cascade
do
|
t
|
create_table
'users'
,
options:
'ENGINE=InnoDB DEFAULT CHARSET=utf8'
,
force: :cascade
do
|
t
|
t
.
string
"name"
,
default:
""
,
null:
false
t
.
string
'name'
,
default:
''
,
null:
false
t
.
string
"prefix"
,
default:
""
t
.
string
'prefix'
,
default:
''
t
.
string
"phone"
,
default:
""
t
.
string
'phone'
,
default:
''
t
.
boolean
"registration"
,
default:
false
t
.
boolean
'registration'
,
default:
false
t
.
text
"address"
t
.
text
'address'
t
.
string
"email"
,
default:
""
,
null:
false
t
.
string
'email'
,
default:
''
,
null:
false
t
.
string
"encrypted_password"
,
default:
""
,
null:
false
t
.
string
'encrypted_password'
,
default:
''
,
null:
false
t
.
string
"reset_password_token"
t
.
string
'reset_password_token'
t
.
datetime
"reset_password_sent_at"
t
.
datetime
'reset_password_sent_at'
t
.
datetime
"remember_created_at"
t
.
datetime
'remember_created_at'
t
.
string
"confirmation_token"
t
.
string
'confirmation_token'
t
.
datetime
"confirmed_at"
t
.
datetime
'confirmed_at'
t
.
datetime
"confirmation_sent_at"
t
.
datetime
'confirmation_sent_at'
t
.
string
"unconfirmed_email"
t
.
string
'unconfirmed_email'
t
.
datetime
"created_at"
,
null:
false
t
.
datetime
'created_at'
,
null:
false
t
.
datetime
"updated_at"
,
null:
false
t
.
datetime
'updated_at'
,
null:
false
t
.
index
[
"confirmation_token"
],
name:
"index_users_on_confirmation_token"
,
unique:
true
t
.
index
[
'confirmation_token'
],
name:
'index_users_on_confirmation_token'
,
unique:
true
t
.
index
[
"email"
],
name:
"index_users_on_email"
,
unique:
true
t
.
index
[
'email'
],
name:
'index_users_on_email'
,
unique:
true
t
.
index
[
"reset_password_token"
],
name:
"index_users_on_reset_password_token"
,
unique:
true
t
.
index
[
'reset_password_token'
],
name:
'index_users_on_reset_password_token'
,
unique:
true
end
end
add_foreign_key
"cities_jobs"
,
"cities"
add_foreign_key
'cities_jobs'
,
'cities'
add_foreign_key
"cities_jobs"
,
"jobs"
add_foreign_key
'cities_jobs'
,
'jobs'
add_foreign_key
"entries"
,
"jobs"
add_foreign_key
'entries'
,
'jobs'
add_foreign_key
"entries"
,
"users"
add_foreign_key
'entries'
,
'users'
add_foreign_key
"favorite_jobs"
,
"jobs"
add_foreign_key
'favorite_jobs'
,
'jobs'
add_foreign_key
"favorite_jobs"
,
"users"
add_foreign_key
'favorite_jobs'
,
'users'
add_foreign_key
"industries_jobs"
,
"industries"
add_foreign_key
'industries_jobs'
,
'industries'
add_foreign_key
"industries_jobs"
,
"jobs"
add_foreign_key
'industries_jobs'
,
'jobs'
add_foreign_key
"jobs"
,
"companies"
add_foreign_key
'jobs'
,
'companies'
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment