From 5d9b2d5fd5f6d4c584cb2c7107e7e558c779da46 Mon Sep 17 00:00:00 2001 From: Levent Ali Date: Tue, 18 Aug 2015 11:09:02 +0100 Subject: [PATCH] Set table_name before including Mixin Included uses respond_to? which queries the incorrect table name --- lib/doorkeeper/orm/active_record/access_grant.rb | 4 ++-- lib/doorkeeper/orm/active_record/access_token.rb | 4 ++-- lib/doorkeeper/orm/active_record/application.rb | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/doorkeeper/orm/active_record/access_grant.rb b/lib/doorkeeper/orm/active_record/access_grant.rb index 4de00c39e..05685aaa9 100644 --- a/lib/doorkeeper/orm/active_record/access_grant.rb +++ b/lib/doorkeeper/orm/active_record/access_grant.rb @@ -1,7 +1,7 @@ module Doorkeeper class AccessGrant < ActiveRecord::Base - include AccessGrantMixin - self.table_name = "#{table_name_prefix}oauth_access_grants#{table_name_suffix}".to_sym + + include AccessGrantMixin end end diff --git a/lib/doorkeeper/orm/active_record/access_token.rb b/lib/doorkeeper/orm/active_record/access_token.rb index 45cea7004..acadffa1d 100644 --- a/lib/doorkeeper/orm/active_record/access_token.rb +++ b/lib/doorkeeper/orm/active_record/access_token.rb @@ -1,9 +1,9 @@ module Doorkeeper class AccessToken < ActiveRecord::Base - include AccessTokenMixin - self.table_name = "#{table_name_prefix}oauth_access_tokens#{table_name_suffix}".to_sym + include AccessTokenMixin + def self.delete_all_for(application_id, resource_owner) where(application_id: application_id, resource_owner_id: resource_owner.id).delete_all diff --git a/lib/doorkeeper/orm/active_record/application.rb b/lib/doorkeeper/orm/active_record/application.rb index 3e3073ccc..4841f4273 100644 --- a/lib/doorkeeper/orm/active_record/application.rb +++ b/lib/doorkeeper/orm/active_record/application.rb @@ -1,9 +1,9 @@ module Doorkeeper class Application < ActiveRecord::Base - include ApplicationMixin - self.table_name = "#{table_name_prefix}oauth_applications#{table_name_suffix}".to_sym + include ApplicationMixin + if ActiveRecord::VERSION::MAJOR >= 4 has_many :authorized_tokens, -> { where(revoked_at: nil) }, class_name: 'AccessToken' else