Check has_one for instance variables as well - #223
fiestacasey wants to merge 1 commit into
Conversation
This is interesting. @fiestacasey does it work if you remove it completely and directly specify what's the name of the attribute via I always wanted to get rid of these extensions, just ot make sure we don't mess up with user implementations. N.B.: Apologies for the delay from my side. |
|
@stas yes that would fix it but we're working with a pretty large monolith and refactoring it out would be a whole hassle. Alternatively removing the extension entirely also resolves the problem and that is what we've done in the meantime on another fork: We would be happy to create a PR for that solution if preferred but it could be a breaking change for someone out there, this solution felt like like a good middle ground. |
@fiestacasey I'm ok making the railtie part optional (maybe via an environmental variable) and adding a deprecation warning with the full removal in v2.5.0. Appreciate if you could prepare a PR 🙇 🙏 |
What is the current behavior?
We have a model that relies on has_one with through and an attribute accessor to find that parent object, something like this:
and this extension breaks the lookup_user_credit because it is dynamically generating the reader function and only checking attributes and not instance variables. I dug through commit history in both this and the previous repo and I can't find the original reason this extension was added but I'm assuming its still needed?
What is the new behavior?
The change dynamically checks instance variables in the same fashion it is already checking attributes.
I did not add a unit test because the current extension is not hit and I'm hoping that this is just straightforward and basic enough to not have to add an entire suite of fixtures and/or rely on real active record models within in spec here but let me know.
Checklist
Please make sure the following requirements are complete:
features)