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
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
9 deletions
+16
-9
app/controllers/entries_controller.rb
+11
-5
app/models/user.rb
+5
-4
db/schema.rb
+0
-0
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
This diff is collapsed.
Click to expand it.
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