x is not a number error??

I may be overlooking something really obvious here but I'm not getting it. I have a Category model. Categories can have sub categories and parent categories, but when a category doesn't have a parent category, its "parent_categoryid" field is set to null. As far as I know, what I am doing here has been working in the past because there are many categories in my categories table with null parent_categoryid fields. For some reason, when I do:

c = Category.find(12345) c.save

It returns false when c.parent_categoryid = NULL, and c.errors says #<ActiveRecord::Errors:0xb708ce08 @errors={"parent_categoryid"=>["is not a number"]}, ...

In the DB on the exact same record, I can do:

update categories set parent_categoryid = NULL where id = 12345;

And it works just fine. Any ideas why I'm getting this problem? I am running Rails v1.2.6, PostgreSQL 8.2.4, and Ruby 1.8.6. The relevant database constraints are:

                                   Table "public.categories"       Column | Type | Modifiers

Naturally, I figure it out 5 minutes after I post the message. Someone slipped a "validates_numericality_of :parent_categoryid" in the Category model without my knowing.

I may be overlooking something really obvious here but I'm not getting it. I have a Category model. Categories can have sub categories and parent categories, but when a category doesn't have a parent category, its "parent_categoryid" field is set to null. As far as I know, what I am doing here has been working in the past because there are many categories in my categories table with null parent_categoryid fields. For some reason, when I do:

c = Category.find(12345) c.save

It returns false when c.parent_categoryid = NULL, and c.errors says #<ActiveRecord::Errors:0xb708ce08 @errors={"parent_categoryid"=>["is not a number"]}, ...

Sounds like you've got a (ActiveRecord) validation on that column.

Fred