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
Nguyen Hoang Mai Phuong
VeNJOB
Commits
d3fde0de
Commit
d3fde0de
authored
Aug 26, 2021
by
Nguyen Hoang Mai Phuong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix validate upload file
parent
8829b3b6
Pipeline
#1405
failed with stages
in 0 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
7 additions
and
6 deletions
+7
-6
app/models/apply_job.rb
+1
-2
app/models/user.rb
+2
-2
app/views/users/registrations/edit.html.slim
+2
-1
app/views/users/registrations/new.html.slim
+2
-1
No files found.
app/models/apply_job.rb
View file @
d3fde0de
...
...
@@ -3,9 +3,8 @@ class ApplyJob < ApplicationRecord
belongs_to
:job
has_one_attached
:cv
validates
:name
,
presence:
true
,
length:
{
maximum:
200
}
VALID_FILE_UPLOAD
=
%w[application/msword application/pdf application/xls application/xlsx application/zip]
.
freeze
VALID_EMAIL_REGEX
=
/\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
validates
:email
,
presence:
true
,
length:
{
maximum:
255
},
format:
{
with:
VALID_EMAIL_REGEX
}
validates
:cv
,
presence:
true
,
content_type:
{
in:
VALID_FILE_UPLOAD
,
message:
'must be a valid pdf format'
},
validates
:cv
,
presence:
true
,
content_type:
{
in:
'application/pdf'
,
message:
'must be a valid pdf format'
},
size:
{
less_than:
5
.
megabytes
,
message:
'should be less than 5MB'
}
end
app/models/user.rb
View file @
d3fde0de
...
...
@@ -3,12 +3,11 @@ class User < ApplicationRecord
has_many
:apply_jobs
,
dependent: :destroy
has_many
:favorite_jobs
,
dependent: :destroy
has_many
:history_jobs
,
dependent: :destroy
VALID_FILE_UPLOAD
=
%w[application/msword application/pdf application/xls application/xlsx application/zip]
.
freeze
devise
:database_authenticatable
,
:registerable
,
:recoverable
,
:rememberable
,
:trackable
,
:validatable
,
:confirmable
validates
:name
,
length:
{
maximum:
200
}
validates
:email
,
length:
{
maximum:
200
},
uniqueness:
true
validates
:cv
,
content_type:
{
in:
VALID_FILE_UPLOAD
,
message:
'must be msword, pdf, xls, xlsx, zip
format'
},
validates
:cv
,
content_type:
{
in:
'application/pdf'
,
message:
'must be a valid pdf
format'
},
size:
{
less_than:
5
.
megabytes
,
message:
'should be less than 5MB'
}
end
\ No newline at end of file
app/views/users/registrations/edit.html.slim
View file @
d3fde0de
...
...
@@ -41,6 +41,6 @@ h2.p-3.text-center
.field
=
f
.
label
:cv
,
"CV"
br
=
f
.
file_field
:cv
,
accept:
User
::
VALID_FILE_UPLOAD
,
size:
{
less_than:
5
.
megabytes
,
message
:"should be less than 5MB"
}
=
f
.
file_field
:cv
,
accept:
'application/pdf'
,
size:
{
less_than:
5
.
megabytes
,
message
:"should be less than 5MB"
}
.actions.p-2.text-center
=
f
.
submit
"Update"
,
class:
"btn btn-primary"
\ No newline at end of file
app/views/users/registrations/new.html.slim
View file @
d3fde0de
...
...
@@ -30,6 +30,6 @@ h2.p-3.text-center
.field
=
f
.
label
:cv
,
"CV"
br
=
f
.
file_field
:cv
,
accept:
User
::
VALID_FILE_UPLOAD
,
size:
{
less_than:
5
.
megabytes
,
message
:"should be less than 5MB"
}
=
f
.
file_field
:cv
,
accept:
'application/pdf'
,
size:
{
less_than:
5
.
megabytes
,
message
:"should be less than 5MB"
}
.actions.p-3.text-center
=
f
.
submit
"Sign up"
,
class:
"btn btn-primary"
\ No newline at end of file
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