Ruby on Rails Thursday, March 17, 2016

How I put a mask on login with devise?

This is my views/devise/sessions/new.html.erb
      <%= simple_form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %>
      <div class="form-inputs">
          <%= f.input :cpf, required: false, autofocus: true, input_html: { class: 'form-control mask-cpf' }, placeholder: 'LOGIN', label: false %>
          <%= f.input :password, required: false, input_html: { class: 'form-control' }, placeholder: 'SENHA', label: false %>
      </div>
      <div class="form-actions">
        <%= f.button :submit, "Log in", :class => "btn btn-default btn-lg btn-block" %>
      </div>
      <% end %>

I need generate the sessions_controller of the devise? Or I just use in User.rb? The mask appear, but when save, save with . and - , because this I cant sign_in :(
My class User, this:

class User < ActiveRecord::Base
  devise :database_authenticatable, :registerable,
         :recoverable, :rememberable, :trackable, :validatable

  before_validation do
    self.cpf.gsub!(/(\.|\-)/, "")
  end

  # validates :cpf, uniqueness: true

end

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/7c8aeaec-cd10-493a-abe1-dec1889b5fe6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment