-
Notifications
You must be signed in to change notification settings - Fork 86
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
Make attributes deserialization "relaxed" #22
Comments
Hi @FunkyloverOne, Thank you for the interest! Your idea sounds pretty reasonable, let's discuss how we can make this change. The problem is that I use def attributes
@attributes.to_hash
end I believe the situation you describe is not a "golden path" and user knows what's going on, so it won't bother him to look up for the "lost" attribute somewhere else–what about |
Hey @DmitryTsepelev, I like it! Thanks for such a quick reply and PR! |
Rolled out 0.5.0, it took a bit more time than I expected |
Hi!
So I was playing around with this gem, and tried the following:
I have defined some JSON-backed model, let's say it was:
Then I have created some record in my DB with filled
model
attribute.Then I have renamed that
model
attribute tosomething_else
.And form this point if I load my stored record from DB, and trying to access JSON-backed model - I'm getting an error:
ActiveModel::UnknownAttributeError
.So I think it's not very flexible. This makes it harder to change that JSON-schema over time.
I think that we could benefit from using same approach as
mongoid
uses here:if JSON has some extra attributes - no errors raised, there's no such attribute, so just "ignore" it, but, that data is still accessible from
attributes
hash.What do you think?
The text was updated successfully, but these errors were encountered: