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
-------------------±--------
±-------------------------------------------------------------------------
id | integer | not null default
nextval(‘categories_id_seq’::regclass)
parent_categoryid | integer |

Indexes:
“categories_parent_categoryid” btree (parent_categoryid)
Foreign-key constraints:
“$1” FOREIGN KEY (parent_categoryid) REFERENCES categories(id) ON
DELETE CASCADE

Thanks for any help you can offer.

Matt

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.

On 19 May 2008, at 23:24, Matt W. wrote:

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