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

user984621
  • 41,002
  • 66
  • 200
  • 371
  • What version of Rails are you using ? I tested your validation code on a Rails app running Ruby 1.9.3 and Rails 3.2.16 and it showed all the customized messages. – Raghavan Kandala Jan 29 '14 at 18:37

0 Answers0