Not seeing error message from validates_format_of

Hi all any help at all on this is much appreciated.

Code is below:

I have a module with the standard Validate for email format and several
validates in it. I have a form with the f.error.messages in it. I submit
the form to the update method in the controller then reload the page
with the data if there is an error. Validation is working, but error
message does not display on reload of the page. Below I actually had to
compare to the error message in the errors object and flash notice the
error to see it on reload of the page. Can anyone tell how to get the
error message to display without the flash notice on the update?

validates_format_of :email_add, :with =>
/\A([^@\s]+)@((?:[-a-z0-9]+.)+[a-z]{2,})\Z/i, :on => :update, :message
=> “Email must be in the format of [email protected]


  • form_for @person, :url => {:action => “update” }, :html => {:id
    =>“aform2”} do |f|
    = f.error_messages
    = f.label “Email Address”
    = f.text_field :email_add

    = hidden_field_tag ‘commit’

def update

# @person is loaded in before_filter
if @person.update_attributes(params[:person])
  flash[:notice] = "Successfully updated person."
  redirect_to @person

   if @person.errors[:email_add] == "Email must be in the format of

[email protected]"
flash[:notice] = @person.errors[:email_add]

  redirect_to :action => 'edit', :id => @person