Skip to content

Fix has_many through association#2478

Closed
jibidus wants to merge 1 commit into
railsadminteam:masterfrom
sogilis:fix_has_many_through_association
Closed

Fix has_many through association#2478
jibidus wants to merge 1 commit into
railsadminteam:masterfrom
sogilis:fix_has_many_through_association

Conversation

@jibidus

@jibidus jibidus commented Nov 18, 2015

Copy link
Copy Markdown
Contributor

Fix has_many association with through issue introduced by #2446.
See #2446 for more details.

Issue fixed: #2474

@jibidus jibidus force-pushed the fix_has_many_through_association branch 2 times, most recently from 23984c1 to df973f8 Compare November 18, 2015 09:01
@jibidus jibidus force-pushed the fix_has_many_through_association branch from df973f8 to 1299482 Compare November 18, 2015 10:30

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure that above fix is safe also for polymorphic association?
Isn't it safe to just nil-guard null call?

klass.columns_hash[foreign_key.to_s].try(:null)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may return nil if key does not exist in klass.columns_hash. Perhaps not the return value we expect.
It should be better to write a test with a polymorphic association and see what happen (and fix potential issue), right ?

  • Write test with polymorphic association

@mshibuya mshibuya closed this in 2c8efe1 Nov 21, 2015
@jibidus

jibidus commented Nov 22, 2015

Copy link
Copy Markdown
Contributor Author

Thanks @mshibuya for your work.

@jibidus jibidus deleted the fix_has_many_through_association branch November 22, 2015 08:33
jibidus pushed a commit to sogilis/rails_admin that referenced this pull request Nov 26, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

#foreign_key_nullable? breaks with has_many through association

2 participants