Commit df6843d5 authored by Gustavo Soviersovski's avatar Gustavo Soviersovski

Add CPF and Full Name Fields User Form

parent 8d35d1eb
......@@ -2,4 +2,10 @@ class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
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
......@@ -3,4 +3,7 @@ class User < ActiveRecord::Base
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
: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+/) }
validates :cpf, numericality: {only_integer: true}
validates :cpf, length: {is: 11}
end
......@@ -3,11 +3,21 @@
<%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %>
<%= devise_error_messages! %>
<div class="field">
<%= f.label :full_name %><br />
<%= f.text_field :full_name, autofocus: true %>
</div>
<div class="field">
<%= f.label :email %><br />
<%= f.email_field :email, autofocus: true %>
</div>
<div class="field">
<%= f.label :cpf %><br />
<%= f.text_field :cpf%>
</div>
<% if devise_mapping.confirmable? && resource.pending_reconfirmation? %>
<div>Currently waiting confirmation for: <%= resource.unconfirmed_email %></div>
<% end %>
......
......@@ -3,9 +3,19 @@
<%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>
<%= devise_error_messages! %>
<div class="field">
<%= f.label :full_name %><br />
<%= f.text_field :full_name, autofocus: true %>
</div>
<div class="field">
<%= 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 class="field">
......
class AddUserCustomFields < ActiveRecord::Migration
def change
add_column :users, :full_name, :string
add_column :users, :cpf, :integer
add_column :users, :institution_name, :string
add_column :users, :cpf, :string
add_column :users, :institution_name, :string
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment