Please sign in to comment.
Refactor Person/Friendship relationships to be more intuitive
PR #5210 added a Friendship model to illustrate a bug, but in doing so created a confusing structure because both belongs_to declarations in Friendship referred to the same side of the join. The new structure maintains the integrity of the bug test while changing the follower relationship to be more useful for other testing.
- Loading branch information...
Showing with 15 additions and 6 deletions.
|@@ -1,4 +1,4 @@|
|- person_id: 1|
|- friend_id: 2|
|+ friend_id: 1|
|+ follower_id: 2|
|@@ -1,4 +1,6 @@|
|class Friendship < ActiveRecord::Base|
|belongs_to :friend, class_name: 'Person'|
|- belongs_to :follower, foreign_key: 'friend_id', class_name: 'Person', counter_cache: :followers_count|
|+ # friend_too exists to test a bug, and probably shouldn't be used elsewhere|
|+ belongs_to :friend_too, foreign_key: 'friend_id', class_name: 'Person', counter_cache: :friends_too_count|
|+ belongs_to :follower, class_name: 'Person'|