Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

reset_counters() breaks with multiple belongs_to having same foreign keys #5200

Closed
Pliny opened this Issue · 10 comments

4 participants

@Pliny

Given this code:

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
class User < ActiveRecord::Base
  has_many :followers, foreign_key: 'friend_id', class_name: 'Friendship'
end

User.reset_counters(id, :follower) crashes

@Pliny Pliny referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
@Pliny Pliny referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
@Pliny Pliny referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
@Pliny Pliny referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
@Pliny Pliny referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
@isaacsanders

Is this still an issue?

@Pliny

Yes, issue still exists with the latest master.

@isaacsanders

It looks like you have done a lot of work on this, do you want to make a pull request?

@Pliny

I did request one.. but in a different thread. #5210. It's been a few months though.

@rafaelfranca
Owner

@Pliny we will take a look in the pull request. Thanks

@Pliny

Thanks @rafaelfranca. Please let me know if anything else is needed from me.

@isaacsanders

Can we close this now that the PR is getting love?

@rafaelfranca

Lets wait the pull request getting merged. This issue was referenced in the pull request so went they will merged I will close this one.

@isaacsanders thank you for your help with the issues triage.

@isaacsanders

No problem!

@schneems
Collaborator

Can we get some more eyes on #5210? It needs to be merged or closed along with this issue.

@Pliny Pliny referenced this issue from a commit in Pliny/rails
@Pliny Pliny This closes issue #5200. reset_counters() was crashing when there wer…
…e multiple belongs_to associations with the same foreign key.
5717654
@Pliny Pliny referenced this issue from a commit in Pliny/rails
@Pliny Pliny Added required test files for #5200 0ce9f2d
@rafaelfranca rafaelfranca closed this issue from a commit
@Pliny Pliny reset_counters() was crashing when there were multiple belongs_to ass…
…ociations with the same foreign key.

This closes #5200.
ff0d9b9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.