On Wed, Feb 8, 2012 at 11:50, David M <idav...@gmail.com> wrote: > class EmailFormatValidator < ActiveModel::EachValidator > def validate_each(object, attribute, value) > unless value =~ /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i > object.errors[attribute] << (options[:message] || 'is not valid') > end > end > end ... > When email is invalid, this is the error shown: > > Email is not valid > > How can I customize the entire string? > > I have tried this way in the custom validator: .... > object.errors[attribute] = "Maybe your email is malformed."
Note the difference in the technique you're using to alter object.errors[attribute] in each case. Try mimicking the original way more closely. Let us know if that works. -Dave -- Dave Aronson: Available Cleared Ruby on Rails Freelancer (NoVa/DC/Remote) -- see www.DaveAronson.com, and blogs at www.Codosaur.us, www.Dare2XL.com, www.RecruitingRants.com -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.