How can I override the AccessToken
class of the Doorkeeper gem?
I already tried creating the class at models/access_token.rb
module Doorkeeper
class AccessToken < ActiveRecord::Base
belongs_to :resource_owner, class_name: 'OauthResourceOwner'
include AccessTokenMixin
def as_json(*)
super.except!(:resource_owner_id).merge!(
owner: {
id: resource_owner&.owner_id,
type: resource_owner&.owner_type&.tableize
}
)
end
end
end
I faced with same issue. And add association in initializer
Doorkeeper::AccessToken.belongs_to :resource_owner, class_name: 'OauthResourceOwner'
在Ruby中,类是“开放的”,这意味着您没有覆盖AccessToken
,而是向AccessToken
添加方法。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.