1

I have this validation rule:

  validates :email, :presence => {:message => 'Email cannot be blank.'}, :allow_blank => true, :format => {:with => /\A[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]+\z/, :message => 'Email is not valid.'}, :uniqueness => true

and I would like to set up own message for

validates :email, :presence => {:message => 'Email cannot be blank.'}, :allow_blank => true, :format => {:with => /\A[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]+\z/, :message => 'Email is not valid.'}, :uniqueness => {message: 'This email address has already been taken.'}

But this generate only the default message has already been taken, not the one I defined in the message part. How to customise it?

Thanks

4

0 回答 0