mardi 21 avril 2015

How to edit error messages in devise

I need to modify the error messages of devise. I want to change the message "is Invalid" to "Es inválido" . The problem is that I have to go to change these messages in the gem. Can I overwrite these messages in the model User

Rails console

1.9.3-p547 :014 > user.save
 => false 
1.9.3-p547 :015 > user.errors
 => {:email=>["is invalid"], :password=>["is too short (minimum is 6 characters)"]} 
1.9.3-p547 :016 > 

User model

class User < ActiveRecord::Base
  # Include default devise modules. Others available are:
  # :token_authenticatable, :confirmable, :lockable and :timeoutable
  devise :database_authenticatable, :registerable,
         :recoverable, :rememberable, :trackable, :validatable

  # Setup accessible (or protected) attributes for your model
  attr_accessible :email, :password, :password_confirmation, :remember_me
end

Aucun commentaire:

Enregistrer un commentaire