Skip to content
  • Carlos Antonio da Silva's avatar
    207ddc51
    Improve support for Devise in apps with multiple ORMs loaded · 207ddc51
    Carlos Antonio da Silva authored
    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 generic `Orm` 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
    207ddc51
    Improve support for Devise in apps with multiple ORMs loaded
    Carlos Antonio da Silva authored
    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 generic `Orm` 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
Loading