Update macro method usage, after receiving undefined error in Mongoid 7.0 #1282
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue: Mongoid with 7.0 patch removed file which contained
macro
method. Formtastic gem relies on this method in various places in code. Currently, projects which use Mongo 7.0 are havingundefined 'macro' method
error.macro
method: https://github.com/mongodb/mongoid/blob/v6.4.4/lib/mongoid/relations/referenced/in.rbrelations
folder and forward files - removed: https://github.com/mongodb/mongoid/tree/v7.0.0/lib/mongoidSolution: To avoid breaking current macro usage and fix the error for Mongoid 7.0 database based projects, a solution with
Proxy Object
was introduced in this pull request. Using Proxy Object allowed fixing macro method issue while keeping gem mostly intact. In the future, if other special issues will appear with the reflection object, fixing them will be easier by modifying this class.