SQL - int not inserted into database correctly

Hello
I’m using writertopia authentication plugin. Looking at the Rails
server output I see the following insert when I call
current_user.has_role ‘moderator’ @group

SQL (0.000154) BEGIN
Role Create (0.000424) INSERT INTO roles (name, updated_at,
authorizable_type, authorizable_id, created_at)
VALUES(‘moderator’, ‘2008-03-10 20:36:37’, ‘Group’, 23, ‘2008-03-10
20:36:37’)
SQL (0.000497) COMMIT

so far so good. I then check the database and instead of having
roles.authorizable_id = 23 it = NULL.

±—±----------±------------------±----------------
±--------------------±--------------------+
| id | name | authorizable_type | authorizable_id |
created_at | updated_at |
±—±----------±------------------±----------------
±--------------------±--------------------+
| 21 | moderator | Group | NULL | 2008-03-10
20:36:37 | 2008-03-10 20:36:37 |
±—±----------±------------------±----------------
±--------------------±--------------------+

If I execute the SQL for the mysql commandline prompt I get the
expected result and a non null authorizable_id.

Any suggestions about how to go about fixing / debugging would be very
appreciated.
Cheers,
Ewan

P.S I have the same problem using Ruby-based MySQL library that ships
with Rails, as I have using the C-based MySQL library.

A new day and I’ve found the problem. Looking further down the Rails
server output I discover I’m updating the roles table and inserting
the null value, inadvertently. I was temporally changing the
association on a model object not realising the changes were save
automatically.