-
Notifications
You must be signed in to change notification settings - Fork 30
Open
Description
Not sure if this is pushing too far, but I get incorrect behavior when trying to use methods like changed? and changes when nilify_blanks is applied to a model.
For example:
--- !ruby/hash:ActiveSupport::HashWithIndifferentAccess
email:
-
- ''
notes:
-
- ''
I had to configure nilify_blanks like this:
nilify_blanks before: :validation
And then do this clunky logic to work around this problem:
# Save referral. We want to track if anything changed to decide how to treat any comments below.
referral.attributes = referral_attributes
# Force nilify_blanks to do its thing before validation so we can check for the true changes.
referral.valid?
# See if there were changes before updating the referral record. (This will always be `false` after we run
# `update`.)
referral_changed = referral.changed?
referral.saveNot sure how involved it would be to fix this or if it would be appropriate to do so. Or is there a better way to do what I'm trying to accomplish?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels