rails-erd
rails-erd copied to clipboard
many through seems have a bug
and I read the code, here might have an issue: (relationship.rb)
ef initialize(domain, associations) # @private :nodoc:
@domain = domain
@reverse_associations, @forward_associations = partition_associations(associations)
assoc = @forward_associations.first || @reverse_associations.first
@source = @domain.entity_by_name(self.class.send(:association_owner, assoc))
@destination = @domain.entity_by_name(self.class.send(:association_target, assoc))
@source, @destination = @destination, @source if assoc.belongs_to?
end
@forward_associations.first || @reverse_associations.first
if @forward_associations or @reverse_associations more than 1 (like 2) would have a problem.
If i use indirect option I found only one direction arrow shown not 2-directions arrow shown. But it should 2-directions arrow show.
Thanks for opening an issue. Is this on an app you can share, or could you provide a mock version of the models and their relationships for me so I can try to reproduce this?
I guess my issue is related:
class FilterDimension < ApplicationRecord
has_many :filters
has_many :filter_choices
has_many :filter_ranges
end
class FilterChoice < ApplicationRecord
belongs_to :filter_dimension
end
class FilterRange < ApplicationRecord
belongs_to :filter_dimension
end
class Filter < ApplicationRecord
belongs_to :filter_dimension
has_many :filter_choices, through: :filter_dimension
has_many :filter_ranges, through: :filter_dimension
end
This ends up with one dotted arrow only (the arrow from Filter
to FilterRange
is missing):