来自引擎的 Monkey 补丁 ActiveAdmin class

Monkey patch ActiveAdmin class from engine

我有一个engine that will be installed over an application that uses Active Admin...

安装 Active Admin 后,我需要 运行 我的引擎安装程序。这将创建一个文件猴子修补活动管理员 class。

文件看起来像这样...

module ActiveAdmin
  module Devise
    # things I need to add...
  end
end

所以,问题是:我需要把这个文件放在哪里,为什么?

我用了Railtie'sinitializer方法。

my_engine/lib/admin_invitable/engine.rb

module MyEngine
  class Engine < ::Rails::Engine
    isolate_namespace MyEngine
    initializer "ativeadmin_invitable_patch" do |app|
      require_relative "activeadmin_invitable_patch"
    end
  end
end

my_engine/lib/admin_invitable/activeadmin_invitable_patch.rb

module ActiveAdmin
  module Devise
    # bla bla
  end
end