airblade/paper_trail — Issue #111: Existing User model conflicts when User has_paper_trail
Author: pmatsinopoulos
Created: 2011-11-17 12:20:58+00:00
State: open

There is a conflict to set a `User` model to be versioned with `paper_trail`.

I have a model 'User' as follows:

class User < ActiveRecord::Base
has_paper_trail

end

The problem is that whenever I call `user#versions` I get an exception:

ActiveRecord::StatementInvalid: Mysql2::Error: Unknown column 'versions.user_id' in 'where clause': SELECT `versions`.* FROM `versions` WHERE (`versions`.user_id = 6)

(exception thrown when called `versions` on a `User` with `id = 6`).

I also have problem when I am trying to save a `User`. I get the following exception:

ActiveRecord::StatementInvalid: Mysql2::Error: Column 'item_id' cannot be null: INSERT INTO `versions` (`event`, `created_at`, `item_id`, `item_type`, `object`, `whodunnit`) VALUES ('update', '2011-11-17 10:38:43', NULL, NULL, '--- ....

which seems that `save` does not populate the `item_id` and `item_type`.