title: Issues with Devise confirmable emails and paper_trail
body: <p>I need some change tracking for my devise User model. I am trying out paper_trail, but it's causing problems when changing emails and reverting. I can demonstrate the problem in a few lines from rails console below:</p>
  
  <pre><code>1.9.3p385 :048 &gt; u = User.create email: 'aaa@bob.com', password: 'password', username: 'bob'
     (0.2ms)  BEGIN
    User Exists (0.3ms)  SELECT 1 AS one FROM `users` WHERE `users`.`email` = BINARY 'aaa@bob.com' LIMIT 1
    User Exists (0.1ms)  SELECT 1 AS one FROM `users` WHERE `users`.`username` = BINARY 'bob' LIMIT 1
    User Exists (0.1ms)  SELECT 1 AS one FROM `users` WHERE `users`.`email` = BINARY 'aaa@bob.com' LIMIT 1
    User Load (0.2ms)  SELECT `users`.* FROM `users` WHERE `users`.`confirmation_token` = 'zNfBSVLJJ9nF4y5sanVU' LIMIT 1
    SQL (0.2ms)  INSERT INTO `users` (`confirmation_sent_at`, `confirmation_token`, `confirmed_at`, `created_at`, `current_sign_in_at`, `current_sign_in_ip`, `email`, `encrypted_password`, `last_sign_in_at`, `last_sign_in_ip`, `remember_created_at`, `reset_password_sent_at`, `reset_password_token`, `roles_mask`, `sign_in_count`, `unconfirmed_email`, `updated_at`, `username`) VALUES ('2013-03-05 13:15:53', 'zNfBSVLJJ9nF4y5sanVU', NULL, '2013-03-05 13:15:53', NULL, NULL, 'aaa@bob.com', '$2a$10$1BrAH1yqgF3qbgkmpMPl/uE0UY792aB8fvYKLksMnyQsn7sM/dY4O', NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, '2013-03-05 13:15:53', 'bob')
    SQL (0.2ms)  INSERT INTO `versions` (`created_at`, `event`, `item_id`, `item_type`, `object`, `whodunnit`) VALUES ('2013-03-05 13:15:53', 'create', 9, 'User', NULL, NULL)
     (1.3ms)  COMMIT
   =&gt; #&lt;User id: 9, username: "bob", email: "aaa@bob.com", encrypted_password: "$2a$10$1BrAH1yqgF3qbgkmpMPl/uE0UY792aB8fvYKLksMnyQs...", reset_password_token: nil, reset_password_sent_at: nil, remember_created_at: nil, sign_in_count: 0, current_sign_in_at: nil, last_sign_in_at: nil, current_sign_in_ip: nil, last_sign_in_ip: nil, created_at: "2013-03-05 13:15:53", updated_at: "2013-03-05 13:15:53", roles_mask: nil, confirmation_token: "zNfBSVLJJ9nF4y5sanVU", confirmed_at: nil, confirmation_sent_at: "2013-03-05 13:15:53", unconfirmed_email: nil&gt;
  1.9.3p385 :049 &gt; u.confirm!
     (0.1ms)  BEGIN
     (0.6ms)  UPDATE `users` SET `confirmation_token` = NULL, `confirmed_at` = '2013-03-05 13:16:23', `updated_at` = '2013-03-05 13:16:23' WHERE `users`.`id` = 9
    SQL (0.4ms)  INSERT INTO `versions` (`created_at`, `event`, `item_id`, `item_type`, `object`, `whodunnit`) VALUES ('2013-03-05 13:16:23', 'update', 9, 'User', '---\nusername: bob\nemail: aaa@bob.com\nencrypted_password: !binary |-\n JDJhJDEwJDFCckFIMXlxZ0YzcWJna21wTVBsL3VFMFVZNzkyYUI4ZnZZS0xr\n c01ueVFzbjdzTS9kWTRP\nreset_password_token: \nreset_password_sent_at: \nremember_created_at: \nsign_in_count: 0\ncurrent_sign_in_at: \nlast_sign_in_at: \ncurrent_sign_in_ip: \nlast_sign_in_ip: \ncreated_at: 2013-03-05 13:15:53.205031000 Z\nupdated_at: 2013-03-05 13:15:53.205031000 Z\nroles_mask: \nconfirmation_token: zNfBSVLJJ9nF4y5sanVU\nconfirmed_at: \nconfirmation_sent_at: 2013-03-05 13:15:53.204780000 Z\nunconfirmed_email: \nid: 9\n', NULL)
     (25.4ms)  COMMIT
   =&gt; true
  1.9.3p385 :050 &gt; u.versions.length
    Version Load (0.5ms)  SELECT `versions`.* FROM `versions` WHERE `versions`.`item_id` = 9 AND `versions`.`item_type` = 'User' ORDER BY created_at ASC, id ASC
   =&gt; 2
  1.9.3p385 :051 &gt; u.email = 'bbb@bob.com'
   =&gt; "bbb@bob.com"
  1.9.3p385 :052 &gt; u.save
     (0.1ms)  BEGIN
    User Exists (0.3ms)  SELECT 1 AS one FROM `users` WHERE (`users`.`email` = BINARY 'bbb@bob.com' AND `users`.`id` != 9) LIMIT 1
    User Exists (0.2ms)  SELECT 1 AS one FROM `users` WHERE (`users`.`username` = BINARY 'bob' AND `users`.`id` != 9) LIMIT 1
    User Exists (0.2ms)  SELECT 1 AS one FROM `users` WHERE (`users`.`email` = BINARY 'bbb@bob.com' AND `users`.`id` != 9) LIMIT 1
     (0.2ms)  UPDATE `users` SET `unconfirmed_email` = 'bbb@bob.com', `updated_at` = '2013-03-05 13:17:07' WHERE `users`.`id` = 9
    SQL (0.2ms)  INSERT INTO `versions` (`created_at`, `event`, `item_id`, `item_type`, `object`, `whodunnit`) VALUES ('2013-03-05 13:17:07', 'update', 9, 'User', '---\nusername: bob\nemail: aaa@bob.com\nencrypted_password: !binary |-\n JDJhJDEwJDFCckFIMXlxZ0YzcWJna21wTVBsL3VFMFVZNzkyYUI4ZnZZS0xr\n c01ueVFzbjdzTS9kWTRP\nreset_password_token: \nreset_password_sent_at: \nremember_created_at: \nsign_in_count: 0\ncurrent_sign_in_at: \nlast_sign_in_at: \ncurrent_sign_in_ip: \nlast_sign_in_ip: \ncreated_at: 2013-03-05 13:15:53.205031000 Z\nupdated_at: 2013-03-05 13:16:23.677037000 Z\nroles_mask: \nconfirmation_token: \nconfirmed_at: 2013-03-05 13:16:23.674113000 Z\nconfirmation_sent_at: 2013-03-05 13:15:53.204780000 Z\nunconfirmed_email: \nid: 9\n', NULL)
    User Load (0.2ms)  SELECT `users`.* FROM `users` WHERE `users`.`confirmation_token` = 'KJHQCtu74MqUSAdczu3Q' LIMIT 1
     (11.2ms)  UPDATE `users` SET `unconfirmed_email` = 'bbb@bob.com', `updated_at` = '2013-03-05 13:17:07', `confirmation_token` = 'KJHQCtu74MqUSAdczu3Q', `confirmation_sent_at` = '2013-03-05 13:17:07' WHERE `users`.`id` = 9
    SQL (0.2ms)  INSERT INTO `versions` (`created_at`, `event`, `item_id`, `item_type`, `object`, `whodunnit`) VALUES ('2013-03-05 13:17:07', 'update', 9, 'User', '---\nusername: bob\nemail: aaa@bob.com\nencrypted_password: !binary |-\n JDJhJDEwJDFCckFIMXlxZ0YzcWJna21wTVBsL3VFMFVZNzkyYUI4ZnZZS0xr\n c01ueVFzbjdzTS9kWTRP\nreset_password_token: \nreset_password_sent_at: \nremember_created_at: \nsign_in_count: 0\ncurrent_sign_in_at: \nlast_sign_in_at: \ncurrent_sign_in_ip: \nlast_sign_in_ip: \ncreated_at: 2013-03-05 13:15:53.205031000 Z\nupdated_at: 2013-03-05 13:16:23.677037000 Z\nroles_mask: \nconfirmation_token: \nconfirmed_at: 2013-03-05 13:16:23.674113000 Z\nconfirmation_sent_at: 2013-03-05 13:15:53.204780000 Z\nunconfirmed_email: \nid: 9\n', NULL)
     (0.5ms)  COMMIT
   =&gt; true
  1.9.3p385 :053 &gt; u.email
   =&gt; "aaa@bob.com"
  1.9.3p385 :054 &gt; u.unconfirmed_email
   =&gt; "bbb@bob.com"
  1.9.3p385 :055 &gt; u.confirm!
     (0.1ms)  BEGIN
    User Exists (0.3ms)  SELECT 1 AS one FROM `users` WHERE (`users`.`email` = BINARY 'bbb@bob.com' AND `users`.`id` != 9) LIMIT 1
    User Exists (0.2ms)  SELECT 1 AS one FROM `users` WHERE (`users`.`username` = BINARY 'bob' AND `users`.`id` != 9) LIMIT 1
    User Exists (0.2ms)  SELECT 1 AS one FROM `users` WHERE (`users`.`email` = BINARY 'bbb@bob.com' AND `users`.`id` != 9) LIMIT 1
     (0.3ms)  UPDATE `users` SET `confirmation_token` = NULL, `confirmed_at` = '2013-03-05 13:18:08', `email` = 'bbb@bob.com', `unconfirmed_email` = NULL, `updated_at` = '2013-03-05 13:18:08' WHERE `users`.`id` = 9
    SQL (0.2ms)  INSERT INTO `versions` (`created_at`, `event`, `item_id`, `item_type`, `object`, `whodunnit`) VALUES ('2013-03-05 13:18:08', 'update', 9, 'User', '---\nusername: bob\nemail: aaa@bob.com\nencrypted_password: !binary |-\n JDJhJDEwJDFCckFIMXlxZ0YzcWJna21wTVBsL3VFMFVZNzkyYUI4ZnZZS0xr\n c01ueVFzbjdzTS9kWTRP\nreset_password_token: \nreset_password_sent_at: \nremember_created_at: \nsign_in_count: 0\ncurrent_sign_in_at: \nlast_sign_in_at: \ncurrent_sign_in_ip: \nlast_sign_in_ip: \ncreated_at: 2013-03-05 13:15:53.205031000 Z\nupdated_at: 2013-03-05 13:17:07.788127000 Z\nroles_mask: \nconfirmation_token: KJHQCtu74MqUSAdczu3Q\nconfirmed_at: 2013-03-05 13:16:23.674113000 Z\nconfirmation_sent_at: 2013-03-05 13:17:07.790567000 Z\nunconfirmed_email: bbb@bob.com\nid: 9\n', NULL)
     (15.4ms)  COMMIT
   =&gt; true
  1.9.3p385 :056 &gt; u.email
   =&gt; "bbb@bob.com"
  1.9.3p385 :057 &gt; u.versions.last.reify.save # revert to before the email confirm
    User Load (0.3ms)  SELECT `users`.* FROM `users` WHERE `users`.`id` = 9 LIMIT 1
     (0.1ms)  BEGIN
    User Exists (0.2ms)  SELECT 1 AS one FROM `users` WHERE (`users`.`email` = BINARY 'aaa@bob.com' AND `users`.`id` != 9) LIMIT 1
    User Exists (0.2ms)  SELECT 1 AS one FROM `users` WHERE (`users`.`username` = BINARY 'bob' AND `users`.`id` != 9) LIMIT 1
    User Exists (0.2ms)  SELECT 1 AS one FROM `users` WHERE (`users`.`email` = BINARY 'aaa@bob.com' AND `users`.`id` != 9) LIMIT 1
     (0.3ms)  UPDATE `users` SET `created_at` = '2013-03-05 13:15:53', `updated_at` = '2013-03-05 13:17:07', `confirmation_token` = 'KJHQCtu74MqUSAdczu3Q', `confirmed_at` = '2013-03-05 13:16:23', `confirmation_sent_at` = '2013-03-05 13:17:07', `unconfirmed_email` = 'aaa@bob.com' WHERE `users`.`id` = 9
    SQL (0.2ms)  INSERT INTO `versions` (`created_at`, `event`, `item_id`, `item_type`, `object`, `whodunnit`) VALUES ('2013-03-05 13:20:13', 'update', 9, 'User', '---\nusername: bob\nemail: bbb@bob.com\nencrypted_password: !binary |-\n JDJhJDEwJDFCckFIMXlxZ0YzcWJna21wTVBsL3VFMFVZNzkyYUI4ZnZZS0xr\n c01ueVFzbjdzTS9kWTRP\nreset_password_token: \nreset_password_sent_at: \nremember_created_at: \nsign_in_count: 0\ncurrent_sign_in_at: \nlast_sign_in_at: \ncurrent_sign_in_ip: \nlast_sign_in_ip: \ncreated_at: 2013-03-05 13:15:53.000000000 Z\nupdated_at: 2013-03-05 13:18:08.000000000 Z\nroles_mask: \nconfirmation_token: \nconfirmed_at: 2013-03-05 13:18:08.000000000 Z\nconfirmation_sent_at: 2013-03-05 13:17:07.000000000 Z\nunconfirmed_email: \nid: 9\n', NULL)
    User Load (0.2ms)  SELECT `users`.* FROM `users` WHERE `users`.`confirmation_token` = 'q9Y5ovWigLySxvz7PsaB' LIMIT 1
     (0.2ms)  UPDATE `users` SET `created_at` = '2013-03-05 13:15:53', `updated_at` = '2013-03-05 13:17:07', `confirmed_at` = '2013-03-05 13:16:23', `confirmation_sent_at` = '2013-03-05 13:20:13', `unconfirmed_email` = 'aaa@bob.com', `confirmation_token` = 'q9Y5ovWigLySxvz7PsaB' WHERE `users`.`id` = 9
    SQL (17.4ms)  INSERT INTO `versions` (`created_at`, `event`, `item_id`, `item_type`, `object`, `whodunnit`) VALUES ('2013-03-05 13:20:13', 'update', 9, 'User', '---\nusername: bob\nemail: bbb@bob.com\nencrypted_password: !binary |-\n JDJhJDEwJDFCckFIMXlxZ0YzcWJna21wTVBsL3VFMFVZNzkyYUI4ZnZZS0xr\n c01ueVFzbjdzTS9kWTRP\nreset_password_token: \nreset_password_sent_at: \nremember_created_at: \nsign_in_count: 0\ncurrent_sign_in_at: \nlast_sign_in_at: \ncurrent_sign_in_ip: \nlast_sign_in_ip: \ncreated_at: 2013-03-05 13:15:53.000000000 Z\nupdated_at: 2013-03-05 13:18:08.000000000 Z\nroles_mask: \nconfirmation_token: \nconfirmed_at: 2013-03-05 13:18:08.000000000 Z\nconfirmation_sent_at: 2013-03-05 13:17:07.000000000 Z\nunconfirmed_email: \nid: 9\n', NULL)
     (7.0ms)  COMMIT
   =&gt; true
  </code></pre>
  
  <p>Now, we have reverted the user to the state before the new email was confirmed:</p>
  
  <pre><code>1.9.3p385 :059 &gt; u = User.where(username: 'bob').first
    User Load (0.4ms)  SELECT `users`.* FROM `users` WHERE `users`.`username` = 'bob' LIMIT 1
   =&gt; #&lt;User id: 9, username: "bob", email: "bbb@bob.com", encrypted_password: "$2a$10$1BrAH1yqgF3qbgkmpMPl/uE0UY792aB8fvYKLksMnyQs...", reset_password_token: nil, reset_password_sent_at: nil, remember_created_at: nil, sign_in_count: 0, current_sign_in_at: nil, last_sign_in_at: nil, current_sign_in_ip: nil, last_sign_in_ip: nil, created_at: "2013-03-05 13:15:53", updated_at: "2013-03-05 13:17:07", roles_mask: nil, confirmation_token: "q9Y5ovWigLySxvz7PsaB", confirmed_at: "2013-03-05 13:16:23", confirmation_sent_at: "2013-03-05 13:20:13", unconfirmed_email: "aaa@bob.com"&gt;
  1.9.3p385 :060 &gt; u.email
   =&gt; "bbb@bob.com"
  1.9.3p385 :061 &gt; u.unconfirmed_email
   =&gt; "aaa@bob.com"
  </code></pre>
  
  <p>As we can see, this is not the state of the User before. I guess this is because Devise detects an email change and what was set as the new email is set as the unconfirmed email. Is there anyway I can bypass this ONLY when reverting to a previous version of this object?</p>
  
  <p>Also, I notice Devise executes 2 <code>USER users</code> statements for a single email update (the 1st being a subset of the 2nd). Any reason for this and is there a fix? It adds an additional, unnecessary version record for the User.</p>