I am trying to validate an email address user has entered. I’ve done the validation in model but its not working. I have used the following in model…
class Employee < ActiveRecord::Base
belongs_to :department
validates_presence_of :emp_name_official
validates_presence_of :emp_name_full
validates_format_of :emp_email_personal, :with=>/^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i, :message=>"Not a valid email format"
end
I am using version 2.0.2 of rails.
And it works fine when I comment the validation line in my model. And also works fine when I give correct email address.
Can anyone tell where I am going wrong.
Following is the error page.

Try this