1
你有任何想法如何覆蓋由門衛gem提供的Doorkeeper::Application
。比方說,我想添加驗證,回調等。 Db表被命名爲auth_applications
。如何覆蓋門衛gem的模型
我創建了一個名爲application.rb的模型,其中包含以下內容,但我的before_create調用未觸發。什麼是最好的方法?
module Doorkeeper
class Application < ActiveRecord::Base
include ApplicationMixin
require 'identicon'
before_create :generate_identicon
def generate_identicon
self.identicon = Identicon.data_url_for name, 128, [255, 255, 255]
end
end
end
根據this SO answer代碼應該聲明爲初始化。不過,我想有一個經典模型,因爲我想添加很多。
感謝。畢竟容易。關閉它。 – olimart 2014-12-04 15:08:23