-
Notifications
You must be signed in to change notification settings - Fork 87
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
Fix AM/AR Dirty plugin issues with AR 5.2 #116
Conversation
9b55ccf
to
466d11e
Compare
Method is private for AR >= 5.2
466d11e
to
7899d05
Compare
@pwim So I found a way to fix the problem while maintaining the current interface. Basically, I realized that any time we need to check if an attribute is a Mobility attribute in the context of attribute changes, we can do this quickly and easily if we track which attributes have changed by Mobility. So I add a method This is not beautiful, but it fixes all (currenty) dirty issues in AR 5.2, should have minimal performance impact (also since it uses I tried to think about how we could do things differently without fallthrough accessors, but the issue is that there is a case where the user (say) does not use locale accessors, and does not specify Also, regardless, any solution I can imagine will have to override So... if specs pass (locally only remaining failures are with the generators), I'd like to merge this and release in 0.3.0 with the changes, so we're (mostly) prepared for the Rails 5.2 launch. |
2c39333
to
f2cb9e6
Compare
Generator spec failures are from an issue in the specs, not the generators themselves. So basically this PR should fix all known issues with Rails 5.2. |
This is required due to a fix in AR 5.2: rails/rails#28661 Previously, `__send__` was used to fetch the value of the attribute before changes, which worked fine with locale accessors like `title_en`. However, with the fix above, `@attributes` is now used, which does not contain translated attributes (let alone locale accessors). Since in general, locale accessors are an open-ended set, we can't treat them the way normal attributes are treated, so we resort to overriding `_read_attribute` to check if the attribute that has changed is one that Mobility changed, and if so use `__send__`. This fixes the issue, although overriding a private method is not ideal.
f2cb9e6
to
fe8c794
Compare
Cool. Took a look at it, and nothing jumps out at me. |
Fixes #115