hyper-mesh icon indicating copy to clipboard operation
hyper-mesh copied to clipboard

Models with associations named the same break on the client

Open adamcreekroad opened this issue 7 years ago • 0 comments

Models:

class Organization < ApplicationRecord
  has_many :memberships, class_name: 'OrganizationMembership', inverse_of: :organization
end

class OrganizationMembership < ApplicationRecord
  belongs_to :organization, inverse_of: :memberships
end

class Team < ApplicationRecord
  has_many :memberships, class_name: 'TeamMembership', inverse_of: :team
end

class TeamMembership < ApplicationRecord
  belongs_to :team, inverse_of: :memberships
end

Let's say Organization 1 has 15 memberships, and Team 1 has 5.

When you're on the client and you call Team.find(1).memberships first, then when you call Organization.find(1).memberships you only get 5 of the 15.

adamcreekroad avatar Jul 18 '17 13:07 adamcreekroad