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
2
Merge Requests
2
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
Thanh Hung Pham
veNJOB
Commits
9ea7fa6a
Commit
9ea7fa6a
authored
Jul 07, 2017
by
Thanh Hung Pham
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload fil
parent
7bc102de
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
34 additions
and
12 deletions
+34
-12
app/controllers/confirmations_controller.rb
+1
-0
app/models/user.rb
+18
-1
app/views/devise/confirmations/information.html.erb
+1
-1
app/views/devise/registrations/edit.html.erb
+13
-10
config/locales/en.yml
+1
-0
No files found.
app/controllers/confirmations_controller.rb
View file @
9ea7fa6a
class
ConfirmationsController
<
Devise
::
ConfirmationsController
class
ConfirmationsController
<
Devise
::
ConfirmationsController
def
update_confirm
def
update_confirm
@user
=
User
.
find_by
(
params
[
:user
][
:id
])
@user
=
User
.
find_by
(
params
[
:user
][
:id
])
@user
.
save_file
(
params
[
:user
][
:cv_name
])
@user
.
skip_password_validation
=
false
@user
.
skip_password_validation
=
false
@user
.
skip_fullname_validation
=
false
@user
.
skip_fullname_validation
=
false
if
@user
.
update_attributes
(
user_params
)
if
@user
.
update_attributes
(
user_params
)
...
...
app/models/user.rb
View file @
9ea7fa6a
class
User
<
ApplicationRecord
class
User
<
ApplicationRecord
attr_accessor
:skip_password_validation
,
:skip_fullname_validation
attr_accessor
:skip_password_validation
,
:skip_fullname_validation
,
:upload
# 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
,
...
@@ -9,4 +9,21 @@ class User < ApplicationRecord
...
@@ -9,4 +9,21 @@ class User < ApplicationRecord
validates
:email
,
length:
{
maximum:
255
},
format:
{
with:
VALID_EMAIL_REGEX
}
validates
:email
,
length:
{
maximum:
255
},
format:
{
with:
VALID_EMAIL_REGEX
}
validates_presence_of
:fullname
,
message:
"can't be empty"
,
unless: :skip_fullname_validation
validates_presence_of
:fullname
,
message:
"can't be empty"
,
unless: :skip_fullname_validation
validates_presence_of
:password
,
message:
"can't be empty"
,
unless: :skip_fullname_validation
validates_presence_of
:password
,
message:
"can't be empty"
,
unless: :skip_fullname_validation
def
save_file
(
upload
)
file_name
=
upload
.
original_filename
if
upload
!=
''
file
=
upload
.
read
file_type
=
file_name
.
split
(
'.'
).
last
new_name_file
=
Time
.
now
.
to_i
name_folder
=
'upload'
new_file_name_with_type
=
"
#{
new_name_file
}
."
+
file_type
image_root
=
"
#{
RAILS
.
root
}
"
Dir
.
mkdir
(
image_root
+
"
#{
name_folder
}
"
)
File
.
open
(
image_root
+
"
#{
name_folder
}
/"
+
new_file_name_with_type
,
'wb'
)
do
|
f
|
f
.
write
(
file
)
end
end
end
end
app/views/devise/confirmations/information.html.erb
View file @
9ea7fa6a
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
<div
class=
"well"
>
<div
class=
"well"
>
<h2>
Register
</h2>
<h2>
Register
</h2>
<%=
form_for
(
resource
,
url:
confirmations_update_confirm_path
(
resource
),
html:
{
method: :post
})
do
|
f
|
%>
<%=
form_for
(
resource
,
url:
confirmations_update_confirm_path
(
resource
),
html:
{
method: :post
}
,
multipart:
true
)
do
|
f
|
%>
<%=
devise_error_messages!
%>
<%=
devise_error_messages!
%>
<div
class=
"form-group"
>
<div
class=
"form-group"
>
...
...
app/views/devise/registrations/edit.html.erb
View file @
9ea7fa6a
<%-
provide
(
:title
,
'
Register
'
)
-%>
<%-
provide
(
:title
,
'
My Page
'
)
-%>
<div
class=
"well"
>
<div
class=
"well"
>
<h2>
Register
</h2>
<h2>
My Page
</h2>
<%=
form_for
(
resource
,
as:
resource_name
,
url:
registration_path
(
resource_name
),
html:
{
method: :put
})
do
|
f
|
%>
<%=
form_for
(
resource
,
as:
resource_name
,
url:
registration_path
(
resource_name
),
html:
{
method: :put
})
do
|
f
|
%>
<%=
devise_error_messages!
%>
<%=
devise_error_messages!
%>
...
@@ -14,23 +14,26 @@
...
@@ -14,23 +14,26 @@
</div>
</div>
<div
class=
"form-group"
>
<div
class=
"form-group"
>
<%=
f
.
label
:password
%>
<br
/>
<%=
f
.
label
:fullname
%>
<%=
f
.
password_field
:password
,
autocomplete:
"off"
,
class:
'form-control'
%>
<%=
f
.
text_field
:fullname
,
class:
'form-control'
%>
<span
class=
"help-block"
>
leave blank if you don't want to change it
</span>
</div>
</div>
<div
class=
"form-group"
>
<div
class=
"form-group"
>
<%=
f
.
label
:password_confirmation
%>
<%=
f
.
label
:cv_name
%>
<%=
f
.
password_field
:password_confirmation
,
autocomplete:
"off"
,
class:
'form-control'
%>
<%=
f
.
file_field
:cv_name
,
class:
'form-control'
%>
</div>
<div
class=
"form-group"
>
<%=
f
.
label
:password
,
'New password'
%>
<br
/>
<%=
f
.
password_field
:password
,
autocomplete:
"off"
,
class:
'form-control'
%>
</div>
</div>
<div
class=
"form-group"
>
<div
class=
"form-group"
>
<%=
f
.
label
:current_password
%>
<%=
f
.
label
:current_password
,
'Old password'
%>
<%=
f
.
password_field
:current_password
,
autocomplete:
"off"
,
class:
'form-control'
%>
<%=
f
.
password_field
:current_password
,
autocomplete:
"off"
,
class:
'form-control'
%>
<span
class=
"help-block"
>
we need your current password to confirm your changes
</span>
</div>
</div>
<%=
f
.
submit
"
Register
"
,
class:
'btn btn-primary'
%>
<%=
f
.
submit
"
Update
"
,
class:
'btn btn-primary'
%>
<%
end
%>
<%
end
%>
<!--
<!--
<h3>Cancel my account</h3>
<h3>Cancel my account</h3>
...
...
config/locales/en.yml
View file @
9ea7fa6a
...
@@ -34,3 +34,4 @@ en:
...
@@ -34,3 +34,4 @@ en:
attributes
:
attributes
:
user
:
user
:
fullname
:
"
Full
Name"
fullname
:
"
Full
Name"
current_password
:
'
Old
password'
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