rails/rails — Issue #5200: reset_counters() breaks with multiple belongs_to having same foreign keys
Author: Pliny
Created: 2012-02-28 02:06:59+00:00
State: open

Given this code:

```ruby
class Friendship < ActiveRecord::Base
belongs_to :friend, class_name: 'User'
belongs_to :follower, foreign_key: 'friend_id', class_name: 'User', counter_cache: :followers_count
end
```

```ruby
class User < ActiveRecord::Base
has_many :followers, foreign_key: 'friend_id', class_name: 'Friendship'
end
```

User.reset_counters(id, :follower) crashes