Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
simcaq_rails
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
simcaq
simcaq_rails
Commits
df6843d5
Commit
df6843d5
authored
Jun 16, 2016
by
Gustavo Soviersovski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add CPF and Full Name Fields User Form
parent
8d35d1eb
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
32 additions
and
3 deletions
+32
-3
app/controllers/application_controller.rb
app/controllers/application_controller.rb
+6
-0
app/models/user.rb
app/models/user.rb
+3
-0
app/views/users/registrations/edit.html.erb
app/views/users/registrations/edit.html.erb
+10
-0
app/views/users/registrations/new.html.erb
app/views/users/registrations/new.html.erb
+11
-1
db/migrate/20160616121811_add_user_custom_fields.rb
db/migrate/20160616121811_add_user_custom_fields.rb
+2
-2
No files found.
app/controllers/application_controller.rb
View file @
df6843d5
...
@@ -2,4 +2,10 @@ class ApplicationController < ActionController::Base
...
@@ -2,4 +2,10 @@ class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
# For APIs, you may want to use :null_session instead.
protect_from_forgery
with: :exception
protect_from_forgery
with: :exception
before_filter
:configure_permitted_parameters
,
if: :devise_controller?
protected
def
configure_permitted_parameters
devise_parameter_sanitizer
.
for
(
:sign_up
)
<<
:full_name
devise_parameter_sanitizer
.
for
(
:sign_up
)
<<
:cpf
end
end
end
app/models/user.rb
View file @
df6843d5
...
@@ -3,4 +3,7 @@ class User < ActiveRecord::Base
...
@@ -3,4 +3,7 @@ class User < ActiveRecord::Base
# :confirmable, :lockable, :timeoutable and :omniauthable
# :confirmable, :lockable, :timeoutable and :omniauthable
devise
:database_authenticatable
,
:registerable
,
devise
:database_authenticatable
,
:registerable
,
:recoverable
,
:rememberable
,
:trackable
,
:validatable
:recoverable
,
:rememberable
,
:trackable
,
:validatable
validates_length_of
:full_name
,
minimum:
2
,
:too_short
=>
"deve ter ao menos duas palavras"
,
tokenizer:
->
(
full_name
)
{
full_name
.
scan
(
/\w+/
) }
val
i
dates
:cpf
,
numericality:
{
only_integer:
true
}
validates
:cpf
,
length:
{
is:
11
}
end
end
app/views/users/registrations/edit.html.erb
View file @
df6843d5
...
@@ -3,11 +3,21 @@
...
@@ -3,11 +3,21 @@
<%=
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!
%>
<div
class=
"field"
>
<%=
f
.
label
:full_name
%>
<br
/>
<%=
f
.
text_field
:full_name
,
autofocus:
true
%>
</div>
<div
class=
"field"
>
<div
class=
"field"
>
<%=
f
.
label
:email
%>
<br
/>
<%=
f
.
label
:email
%>
<br
/>
<%=
f
.
email_field
:email
,
autofocus:
true
%>
<%=
f
.
email_field
:email
,
autofocus:
true
%>
</div>
</div>
<div
class=
"field"
>
<%=
f
.
label
:cpf
%>
<br
/>
<%=
f
.
text_field
:cpf
%>
</div>
<%
if
devise_mapping
.
confirmable?
&&
resource
.
pending_reconfirmation?
%>
<%
if
devise_mapping
.
confirmable?
&&
resource
.
pending_reconfirmation?
%>
<div>
Currently waiting confirmation for:
<%=
resource
.
unconfirmed_email
%>
</div>
<div>
Currently waiting confirmation for:
<%=
resource
.
unconfirmed_email
%>
</div>
<%
end
%>
<%
end
%>
...
...
app/views/users/registrations/new.html.erb
View file @
df6843d5
...
@@ -3,9 +3,19 @@
...
@@ -3,9 +3,19 @@
<%=
form_for
(
resource
,
as:
resource_name
,
url:
registration_path
(
resource_name
))
do
|
f
|
%>
<%=
form_for
(
resource
,
as:
resource_name
,
url:
registration_path
(
resource_name
))
do
|
f
|
%>
<%=
devise_error_messages!
%>
<%=
devise_error_messages!
%>
<div
class=
"field"
>
<%=
f
.
label
:full_name
%>
<br
/>
<%=
f
.
text_field
:full_name
,
autofocus:
true
%>
</div>
<div
class=
"field"
>
<div
class=
"field"
>
<%=
f
.
label
:email
%>
<br
/>
<%=
f
.
label
:email
%>
<br
/>
<%=
f
.
email_field
:email
,
autofocus:
true
%>
<%=
f
.
email_field
:email
%>
</div>
<div
class=
"field"
>
<%=
f
.
label
:cpf
%>
<br
/>
<%=
f
.
text_field
:cpf
%>
</div>
</div>
<div
class=
"field"
>
<div
class=
"field"
>
...
...
db/migrate/20160616121811_add_user_custom_fields.rb
View file @
df6843d5
class
AddUserCustomFields
<
ActiveRecord
::
Migration
class
AddUserCustomFields
<
ActiveRecord
::
Migration
def
change
def
change
add_column
:users
,
:full_name
,
:string
add_column
:users
,
:full_name
,
:string
add_column
:users
,
:cpf
,
:
integer
add_column
:users
,
:cpf
,
:
string
add_column
:users
,
:institution_name
,
:string
add_column
:users
,
:institution_name
,
:string
end
end
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