Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
VenJob
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
0
Merge Requests
0
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
Mai Hoang Thai Ha
VenJob
Commits
bd849737
Commit
bd849737
authored
Aug 02, 2021
by
Mai Hoang Thai Ha
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add form apply confirm done
parent
f2c78d06
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
61 additions
and
19 deletions
+61
-19
Gemfile
+1
-0
Gemfile.lock
+5
-4
app/controllers/applies_controller.rb
+18
-3
app/models/apply_job.rb
+10
-0
app/views/applies/confirm.html.slim
+22
-7
app/views/applies/new.html.slim
+4
-4
config/routes.rb
+1
-1
No files found.
Gemfile
View file @
bd849737
...
...
@@ -33,6 +33,7 @@ group :development, :test do
gem
'
byebug
'
,
platforms:
[
:mri
,
:mingw
,
:x64_mingw
]
gem
'
pry-rails
'
,
'~> 0.3.9'
# gem '
pry-nav
', '~> 0.3.0'
gem
'
pry
'
,
'~> 0.14.1'
end
group
:development
do
...
...
Gemfile.lock
View file @
bd849737
...
...
@@ -120,7 +120,7 @@ GEM
mail (2.7.1)
mini_mime (>= 0.1.1)
marcel (1.0.1)
method_source (
0.9.2
)
method_source (
1.0.0
)
mime-types (3.3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2021.0704)
...
...
@@ -135,9 +135,9 @@ GEM
parallel (1.20.1)
parser (3.0.2.0)
ast (~> 2.4.1)
pry (0.1
2.2
)
coderay (~> 1.1
.0
)
method_source (~>
0.9
.0)
pry (0.1
4.1
)
coderay (~> 1.1)
method_source (~>
1
.0)
pry-rails (0.3.9)
pry (>= 0.10.4)
public_suffix (4.0.6)
...
...
@@ -275,6 +275,7 @@ DEPENDENCIES
listen (~> 3.3)
mysql2 (~> 0.5)
nokogiri (~> 1.11, >= 1.11.7)
pry (~> 0.14.1)
pry-rails (~> 0.3.9)
puma (~> 5.0)
rack-mini-profiler (~> 2.0)
...
...
app/controllers/applies_controller.rb
View file @
bd849737
...
...
@@ -4,18 +4,29 @@ class AppliesController < ApplicationController
end
def
create
binding
.
pry
@apply
=
@job
.
apply_jobs
.
build
(
apply_params
)
@apply
.
user_id
=
1
# @apply.cv.attach(params[:apply_job][:cv])
if
@apply
.
save
#afasf
else
render
'new'
end
end
def
show
end
def
new
# if params[:job_id].present?
# @job = Job.find_by(id: params[:job_id])
# end
@apply
=
@job
.
apply_jobs
.
build
end
def
confirm
@name
=
params
[
:apply_job
][
:user_name
]
@email
=
params
[
:apply_job
][
:email
]
@cv
=
params
[
:apply_job
][
:cv
]
end
private
...
...
@@ -23,4 +34,8 @@ class AppliesController < ApplicationController
def
load_job
@job
=
Job
.
find_by
(
id:
params
[
:job_id
])
end
def
apply_params
params
.
require
(
:apply_job
).
permit
(
:user_name
,
:email
,
:cv
)
end
end
app/models/apply_job.rb
View file @
bd849737
class
ApplyJob
<
ApplicationRecord
VALID_EMAIL_REGEX
=
/\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
belongs_to
:job
belongs_to
:user
has_one_attached
:cv
validates
:user_name
,
presence:
true
,
length:
{
maximum
:
50
}
validates
:email
,
presence:
true
,
length:
{
maximum
:
255
},
format:
{
with:
VALID_EMAIL_REGEX
},
uniqueness:
true
# validates :image, content_type
# size: { less_than: 5.megabytes,
# message: "should be less than 5MB" }
end
app/views/applies/confirm.html.slim
View file @
bd849737
-
provide
(
:title
,
"Apply job"
)
.container
h1
.my-5.text-center
|
Apply for
|
Confirm
=
@job
.
title
.col
=
form_with
(
url:
confirm_path
,
local:
true
)
do
|
f
|
=
form_with
(
scope: :apply_job
,
url:
done_path
(
job_id:
@job
)
,
local:
true
)
do
|
f
|
.mb-3
=
f
.
label
:name
,
'Full name'
,
class:
'form-label'
=
f
.
text_field
:name
,
class:
'form-control'
=
f
.
label
:name
,
'Full name:'
,
class:
'form-label'
span
.mx-2
=
@name
=
f
.
hidden_field
:user_name
,
value:
@name
,
class:
'form-control'
.mb-3
=
f
.
label
:email
,
class:
'form-label'
=
f
.
email_field
:email
,
class:
'form-control'
=
f
.
label
:email
,
'Email:'
,
class:
'form-label'
span
.mx-2
=
@email
=
f
.
hidden_field
:email
,
value:
@email
,
class:
'form-control'
span
.mb-3.d-block.align-center
=
f
.
label
:cv
,
'Cv:'
,
class:
'form-label'
/ = f.hidden_field :cv, value: @cv
=
f
.
file_field
:cv
=
f
.
submit
"Submit"
,
class:
"btn btn-primary"
span
.mx-2
=
@cv
.
original_filename
=
link_to
'Edit'
,
apply_path
(
job_id:
@job
.
id
),
class:
"btn btn-secondary py-2 px-4"
=
f
.
submit
"Confirm"
,
class:
"btn btn-primary"
app/views/applies/new.html.slim
View file @
bd849737
...
...
@@ -4,13 +4,13 @@
|
Apply for
=
@job
.
title
.col
=
form_with
(
url:
confirm_path
,
local:
true
)
do
|
f
|
=
form_with
(
model:
@apply
,
url:
confirm_path
(
job_id:
@job
)
,
local:
true
)
do
|
f
|
.mb-3
=
f
.
label
:name
,
'Full name'
,
class:
'form-label'
=
f
.
text_field
:name
,
class:
'form-control'
=
f
.
label
:
user_
name
,
'Full name'
,
class:
'form-label'
=
f
.
text_field
:
user_
name
,
class:
'form-control'
.mb-3
=
f
.
label
:email
,
class:
'form-label'
=
f
.
email
_field
:email
,
class:
'form-control'
=
f
.
text
_field
:email
,
class:
'form-control'
span
.mb-3.d-block.align-center
=
f
.
file_field
:cv
=
f
.
submit
"Submit"
,
class:
"btn btn-primary"
config/routes.rb
View file @
bd849737
...
...
@@ -12,5 +12,5 @@ Rails.application.routes.draw do
get
'/apply'
,
to:
'applies#new'
post
'/confirm'
,
to:
'applies#confirm'
post
'/done'
,
to:
'applies#
don
e'
post
'/done'
,
to:
'applies#
creat
e'
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