title: Rails counter_cache not updating correctly
body: <p>Using Rails 3.1.3 and I'm trying to figure out why our counter caches aren't being updated correctly when changing the parent record id via update_attributes.</p>
  
  <pre><code>class ExhibitorRegistration &lt; ActiveRecord::Base
    belongs_to :event, :counter_cache =&gt; true
  end
  
  class Event &lt; ActiveRecord::Base
    has_many :exhibitor_registrations, :dependent =&gt; :destroy
  end
  
  describe ExhibitorRegistration do
    it 'correctly maintains the counter cache on events' do
      event = Factory(:event)
      other_event = Factory(:event)
      registration = Factory(:exhibitor_registration, :event =&gt; event)
  
      event.reload
      event.exhibitor_registrations_count.should == 1
  
      registration.update_attributes(:event_id =&gt; other_event.id)
  
      event.reload
      event.exhibitor_registrations_count.should == 0
  
      other_event.reload
      other_event.exhibitor_registrations_count.should == 1
    end
  end
  </code></pre>
  
  <p>This spec fails indicating that the counter cache on event is not being decremented.</p>
  
  <pre><code>1) ExhibitorRegistration correctly maintains the counter cache on events
     Failure/Error: event.exhibitor_registrations_count.should == 0
       expected: 0
            got: 1 (using ==)
  </code></pre>
  
  <p>Should I even expect this to work or do I need to manually track the changes and update the counter myself?</p>