mercredi 22 avril 2015

error in validates_confirmation devise ruby on rails

I need shows a error in the console or in the browser when the user doesn't write anything in the text field called password-confirmation. The problem is that devise doesn't create an attribute password-confirmation in the model User Other problem that I have is that when I show a error message the name of the attribute automatically is added before the message

Console

1.9.3-p547 :013 > User
 => User(id: integer, email: string, encrypted_password: string, password_salt: string, reset_password_token: string, remember_token: string, remember_created_at: datetime, sign_in_count: integer, current_sign_in_at: datetime, last_sign_in_at: datetime, current_sign_in_ip: string, last_sign_in_ip: string, created_at: datetime, updated_at: datetime) 
1.9.3-p547 :014 > 

devise.en.yml

   en:
  activerecord:
    errors:
      models:
        user:
          attributes:
            email:
              invalid: "Es inválido"
              blank: "No puede estar vacío"
            password:
              blank: "No puede estar vacío"  
              too_short: "La contraseña es demasiado corta"
              confirmation: "Las contraseñas deben ser iguales"
            password_confirmation:
              blank: "No puede estar vacía"
              messages:
      not_found: "no encontrado/a"
      already_confirmed: "ya fue confirmado/a"
      not_locked: "no ha sido bloqueado/a"

Aucun commentaire:

Enregistrer un commentaire