composite-primary-keys / composite_primary_keys

Composite Primary Keys support for Active Record
1.03k stars 350 forks source link

Fix Error for Array-Based Composite Keys in nested_attribute #613

Closed yebityon closed 11 months ago

yebityon commented 11 months ago

Problem Description

I recently updated my project to Rails 6 and faced a testing error when passing a composite key as an array to nested_attribute.

I have added a test case for this error. Please refer to this test case if necessary.

PR Description

Since this commit, record detection in nested_attributes.rb has been conducted using the detect method instead of cpk_detect_record.

I could not find any mention of this change, and considering that cpk_detect_record still exists in nested_attributes.rb but is not used, I created this PR.

This PR reverts to the approach used prior to the introduction of this PR.

If we are intended to use CompositePrimaryKeys::CompositeKeys for creating id as demonstrated in the test case (i.e., if the above change was intentional), I will close this PR.

Also, a quick thanks to the maintainers for their ongoing work on the project 👍

cfis commented 11 months ago

Looks good to me - thanks!