Improve support for Devise in apps with multiple ORMs loaded #5576
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.
Devise is able to work with a specific ORM, either Active Record or Mongoid, but nothing stops apps from using multiple ORMs within the same application -- they just need to pick one to use with Devise. That's generally determined by the require that is added to the Devise initializer, that will load up either ORM's extensions so you can call things like
devise
on your model to set it up.However, some conditional logic in Devise, more specifically around dirty tracking, was only considering having Active Record loaded up after a certain version, to determine which methods to call in parts of the implementation. In a previous change we refactored all that dirty tracking code into this
OrmDirtyTracking
module to make it easier to view all the methods that were being conditionally called, and now we're repurposing this into a more genericOrm
module (that's nodoc'ed by default) so that upon including it, we can conditionally include the proper dirty tracking extensions but also check whether the including model is really Active Record or not, so we can trigger the correct dirty tracking behavior for Mongoid as well if both are loaded on the same app, whereas previously the Mongoid behavior would always use the new Active Record behavior, but support may differ.While we are also working to ensure the latest versions of Mongoid are fully running with Devise, this should improve the situation by giving apps with multiple ORMs loaded a chance to rely on some of these Devise bits of functionality better now that weren't working properly before without some monkey-patching on their end.
Closes #5539
Closes #4542