在我的插件中,我从引擎继承了几个模型并添加了移动设置。
# my enginge
module MyEngine
class Foo < ApplicationRecord
def self.say_hi
return "hi"
end
end
end
# my plugin
require 'my-engine'
module MyEngine
class Foo
include Mobility
translates :name, type: :string
end
end
现在,如果我在 Rails 控制台中查找模型:
MyEngine::Foo.say_hi
ArgumentError: KeyValue backend can only be used by ActiveRecord or Sequel models
如果我注释掉移动设置一切正常:
MyEngine::Foo.say_hi
=> "hi"
如何在我的应用程序中扩展 AR 模型MyEngine::Foo
,以便 Mobility 不会抱怨?