title: Receiving "Attempted to update a stale object: User" exception when updating current_user before logging out
body: <p>I enabled optimistic locking on my User model to handle possible conflicts in various parts of my codebase. However, I'm experiencing an unexpected conflict and I don't know how to handle it because I don't know what's causing it.</p>
  
  <p>I'm using the Devise gem for authentication and I'm using the before_logout method to reset a security token...</p>
  
  <pre><code>class SessionsController &lt; Devise::SessionsController
    after_filter :after_login, :only =&gt; :create
    before_filter :before_logout, :only =&gt; :destroy
  
    def after_login
      # logic to set the security token
    end
  
    def before_logout
      current_user.update(security_token: nil) # &lt;--"Attempted to update a stale object: User"
    end
  end
  </code></pre>
  
  <p>I'm new to Rails (only a few weeks in), so I don't really know where else in my code to look or why this code is throwing the exception. Any suggestions or ideas are greatly appreciated.</p>
  
  <p>Thanks in advance for your wisdom!</p>