Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[403] Allows foreign key to_sym on Array #408

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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