zipcode validation doesn't work

I am trying to do a very basic zipcode validation(zip is a int field in mysql).

validates_presence_of :zip, :message => "Can't be blank" validates_format_of :zip, :with => /^[0-9]{5}(-[0-9]{4})?$/, :message => "Invalid Zipcode"

No matter whatever valid 5 digit zip I enter, this does not work, but If I do a '12345'.match (/^[0-9]{5}(-[0-9]{4})?$/) it works just fine!

It seems both validations fail, the message says "Can't be blank and shold be 5 digits", when its actually both.

I am trying to do a very basic zipcode validation

** (zip is a int field in mysql) **

validates_format_of :zip, :with => /^[0-9]{5}(-[0-9]{4})?$/

Uh, you're trying to use a regular expression on an int? Off the top of my head that seems unlikely to work...

No matter whatever valid 5 digit zip I enter, this does not work, but If I do a '12345'.match (/^[0-9]{5}(-[0-9]{4})?$/) it works just fine!

.. as the above would seem to confirm.

HTH,

Thanks, I did change the field to varchar(5) as well, that doesn't work eitehr

Nevermind, I did not put zip in attr_accessible, that's why it was failing. Doh!!