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

Fix association_parser #44

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

rodrigoulisses
Copy link
Contributor

ActionController::Parameters does not implement method map.

ActionController::Parameters does not implement method map.
Copy link
Owner

@carlosantoniodasilva carlosantoniodasilva left a comment

Choose a reason for hiding this comment

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

@rodrigoulisses the changes look good, but I'm afraid to_hash might raise an error for unpermitted parameters, I'll have to look into it and maybe adding some tests with AC::Parameters before merging this.

Did you hit any issue with a specific Rails version that you could give me more info? Thanks!

@@ -19,7 +19,7 @@ def initialize(target_class, association_name)
#
def parse(attributes)
if association.macro == :has_many
attributes = attributes.is_a?(Hash) ? attributes.values : attributes
attributes = attributes.respond_to?(:to_hash) ? attributes.to_hash.values : attributes

Choose a reason for hiding this comment

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

Question: won't to_hash raise a deprecation warning in 5.0, and an exception in 5.1, when unpermitted? I guess we might need to add some tests with AC::Parameters to be sure.

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.

2 participants