Open kurt-mueller-osumc opened 4 years ago
It seems to be happening here:
# Returns +true+ if this attribute is used as a foreign key for any
# relationship.
def foreign_key?
@domain.relationships_by_entity_name(@model.name).map(&:associations).flatten.map { |associaton|
associaton.send(Domain.foreign_key_method_name)
}.include?(name)
end
I dropped a binding.pry
debugging statement into the code:
13] pry(#<RailsERD::Domain::Attribute>)> whereami
From: .../rails-erd-1.6.0/lib/rails_erd/domain/attribute.rb:80 RailsERD::Domain::Attribute#foreign_key?:
79: def foreign_key?
=> 80: binding.pry
81: @domain.relationships_by_entity_name(@model.name).map(&:associations).flatten.map { |associaton|
82: associaton.send(Domain.foreign_key_method_name)
83: }.include?(name)
84: end
[14] pry(#<RailsERD::Domain::Attribute>)> @model.name
=> "Sample"
[15] pry(#<RailsERD::Domain::Attribute>)> name
=> "patient_mrn"
[16] pry(#<RailsERD::Domain::Attribute>)> @domain.relationships_by_entity_name(@model.name).map(&:associations).flatten.map { |associaton|
[16] pry(#<RailsERD::Domain::Attribute>)* associaton.send(Domain.foreign_key_method_name)
[16] pry(#<RailsERD::Domain::Attribute>)* }
=> [:patient_mrn, :patient_mrn, :sample_id]
[17] pry(#<RailsERD::Domain::Attribute>)> _.include?(name)
=> false
I have a foreign key specified in the database that isn't reflected when I create an er diagram.
The
.erdconfig
file:The ER Diagram
The gem seems to mark columns as foreign keys only if the
column
andforeign_key
attribute are the default types. Override them andFK
won't show up in the er diagram.