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
AC::Parameters no longer being a Hash has broken nested attributes #20922
Comments
Yes. Experiencing this issue as well. |
Needs test coverage in addition to a fix. The current test suite is passing. |
/cc @sikachu |
I've pushed a fix for this problem, and added an isolated test case for it. However I'm going to leave this issue open. This should have never passed CI and I consider our lack of integration test coverage a bug. We need to make sure that we have the tests required to prevent this from happening in the future. |
Thank you, Sean, for looking into this! However, with
|
I've opened a separate issue for the testing problem. |
I forgot the link (#20945) |
Since AC::Parameters is no longer derived from Hash, and each nested "hash" inside Parameters is also an instance of AC::Parameters, https://github.com/rails/rails/blob/master/activerecord/lib/active_record/nested_attributes.rb#L446 raises an error since it only allows Hash or Array, https://github.com/rails/rails/blob/master/activerecord/lib/active_record/nested_attributes.rb#L446 calls #map which isnt supported on AC::Parameters, and https://github.com/rails/rails/blob/master/activerecord/lib/active_record/nested_attributes.rb#L471 calls #with_indifferent_access which isn't supported on AC::Parameters.
I'm willing to submit a fix if wanted, just wondered whether the preferred solution would be to have AC::Parameters call #to_h on accessed elements so they return filtered hashes rather than AC::Parameters instances, or update the nested_attributes code to support AC::Parameters
The text was updated successfully, but these errors were encountered: