-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
attributes_for does not use initialize_with like the docs states it does #1606
Comments
Good catch. The documentation is incorrect. But since you bring it up I should ask: did you want |
@mike-burns, I do similarly to what the reproduction script shows. Essentially, I want to not assign attributes if the sentinel value is present, because I'm tracking assignment of these attributes (where even |
Description
According to the docs,
attributes_for
constructs a hash usinginitialize_with
, but this isn't actually the case.Is this a bug, or incorrect documentation?
Reproduction Steps
Reproduction script: https://gist.github.com/ezekg/7738249c671e48c0372884c847e2559f
Expected behavior
The
initialize_with
callback is used during creation of theattributes_for
hash.Actual behavior
The
initialize_with
callback is not used for theattributes_for
hash.System configuration
factory_bot version: v6.4.2
rails version: v7.1.2
ruby version: v3.2.2
The text was updated successfully, but these errors were encountered: