SQL - int not inserted into database correctly

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
  SQL (0.000497) COMMIT

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

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