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

Normalization not triggered when attribute modified without assignment operator #85

Open
jaredmoody opened this issue Jan 16, 2020 · 0 comments

Comments

@jaredmoody
Copy link

For example, if you are normalizing an array attribute and you do any of the following:

book.categories.push('fiction')
book.categories << 'fiction'

Normalizing an array might not be a common use case - perhaps changing a string via destructive method like gsub! or similar might also cause this.

From skimming the code this looks to be because normalization only happens via override of the assignment operator.

One idea to handle this might be to normalize via callback if included via ActiveModel/ActiveRecord I guess, but seems like that would be a pretty big change so maybe "won't fix" is appropriate here.

Perhaps a mention in the documentation that normalization only happens when using the assignment operator - or that destructive methods are not compatible would be helpful. From just reading the docs, this wasn't clear to me.

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

No branches or pull requests

1 participant