-
Notifications
You must be signed in to change notification settings - Fork 35
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
String attr_json attributes does not get stripped using strip_attributes #151
Comments
Hi, thanks for the question, and the clear observed/expected/example bug report! What do you mean by "the gem itself is stripping the attributes before validation"? Can you try setting rails_attribute: true when you define the attributes, and see if that makes any difference? (I mean to make this always on in a future 2.0 release). Otherwise, I'm not sure, it's possible that the strip_attributes gem just works using Rails API that doesn't apply to the way attr_json works. I don't really have time to debug it myself at the moment, but would be happy to hear and respond to anything anyone else finds from more debugging, or review a PR! |
Hi, |
Looks like the strip_attributes gem uses the I am doing some refactoring of internal attr_json things for a 2.x release, and I was wondering if this might be enough to make if Alternately, you could try to write your own code using As it is, they are not compatible, and there isn't any great path on this end to making them compatible. I'm going to close this ticket for now! Thanks for the report! |
Note that a change to I do think we need some good answer for stripping with attr_json, I'm thinking on it and hope to have something in upcoming v2 release. |
Hi,
I wanted to use the
strip_attributes
gem to strip white spaces from a string attr_json attribute,which surprisingly does not work.
Current behaviour:
Given a model using the
strip_attributes
gem for all attributes,When a string attr_json field is changed with a string including whitespaces,
Then the string attr_json attribute is not stripped of white spaces.
My expected behaviour:
Given a model using the
strip_attributes
gem for all attributes,When a string attr_json field is changed with a string including whitespaces,
Then the string attr_son attribute is stripped of white spaces.
Example of the current behaviour:
Model
Testing from the console to keep is simple:
I'm not sure why it does not work with attr_json attributes, the gem itself is stripping the attributes before validation.
Any thoughts?
The text was updated successfully, but these errors were encountered: