Skip to content

Commit

Permalink
Merge pull request #1472 from doorkeeper-gem/fix-establish_connection…
Browse files Browse the repository at this point in the history
…-for-custom-models

Fix `establish_connection` configuration for custom defined models
  • Loading branch information
nbulaj authored Jan 14, 2021
2 parents c58a7ea + c7f1e5c commit ebd5c04
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ User-visible changes worth mentioning.
## master

- [#PR ID] Add your PR description here.
- [#1472] Fix `establish_connection` configuration for custom defined models.
- [#1471] Add support for Ruby 3.0.
- [#1469] Check if `redirect_uri` exists.
- [#1465] Memoize nil doorkeeper_token.
Expand Down
2 changes: 2 additions & 0 deletions lib/doorkeeper/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ def configure(&block)
@config
end

# @return [Doorkeeper::Config] configuration instance
#
def configuration
@config || (raise MissingConfiguration)
end
Expand Down
9 changes: 4 additions & 5 deletions lib/doorkeeper/orm/active_record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ def self.initialize_models!
require "doorkeeper/orm/active_record/access_token"
require "doorkeeper/orm/active_record/application"

if Doorkeeper.config.active_record_options[:establish_connection]
if (options = Doorkeeper.config.active_record_options[:establish_connection])
Doorkeeper::Orm::ActiveRecord.models.each do |model|
options = Doorkeeper.config.active_record_options[:establish_connection]
model.establish_connection(options)
end
end
Expand Down Expand Up @@ -51,9 +50,9 @@ def self.lazy_load(&block)

def self.models
[
Doorkeeper::AccessGrant,
Doorkeeper::AccessToken,
Doorkeeper::Application,
Doorkeeper.config.access_grant_model,
Doorkeeper.config.access_token_model,
Doorkeeper.config.application_model,
]
end
end
Expand Down

0 comments on commit ebd5c04

Please sign in to comment.