Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
GitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
Fix AM/AR Dirty plugin issues with AR 5.2 #116
@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.
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.