Skip to content

Commit

Permalink
Do not instantiate ActiveRecord model early
Browse files Browse the repository at this point in the history
Do not instantiate active record models before loading active record, as
it can cause several side effects.

Fixes doorkeeper-gem#1703
  • Loading branch information
tachyons-gitlab committed May 12, 2024
1 parent 8626b85 commit 9f5e0f5
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/doorkeeper/orm/active_record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9f5e0f5

Please sign in to comment.