diff --git a/lib/doorkeeper/orm/active_record.rb b/lib/doorkeeper/orm/active_record.rb index 8cfa49e34..0bab10734 100644 --- a/lib/doorkeeper/orm/active_record.rb +++ b/lib/doorkeeper/orm/active_record.rb @@ -33,12 +33,14 @@ def self.run_hooks end def self.initialize_configured_associations - if Doorkeeper.config.enable_application_owner? - Doorkeeper.config.application_model.include ::Doorkeeper::Models::Ownership - end + ActiveSupport.on_load(:active_record) do + if Doorkeeper.config.enable_application_owner? + Doorkeeper.config.application_model.include ::Doorkeeper::Models::Ownership + end - Doorkeeper.config.access_grant_model.include ::Doorkeeper::Models::PolymorphicResourceOwner::ForAccessGrant - Doorkeeper.config.access_token_model.include ::Doorkeeper::Models::PolymorphicResourceOwner::ForAccessToken + Doorkeeper.config.access_grant_model.include ::Doorkeeper::Models::PolymorphicResourceOwner::ForAccessGrant + Doorkeeper.config.access_token_model.include ::Doorkeeper::Models::PolymorphicResourceOwner::ForAccessToken + end end end end