Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions lib/rails_erd/domain/attribute.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,18 @@ def primary_key?
# 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).to_sym
}.include?(name.to_sym)
@domain
.relationships_by_entity_name(@model.name)
.map(&:associations)
.flatten
.map do |associaton|
result = associaton.send(Domain.foreign_key_method_name)
if result.class == Array
result.join("_").to_sym
else
result.to_sym
end
end.include?(name.to_sym)
end

# Returns +true+ if this attribute is used for single table inheritance.
Expand Down