Question

I would like to move some of the code from app/admin folder to an external gem.

I've tried it several times and not very successfully — page in ActiveAdmin doesn't show up.

Can someone point me in some direction?

Was it helpful?

Solution 2

Finally, found a solution.

To add your custom pages to activeadmin inside your gem, you need to use ActiveAdmin.before_load with load_paths attribute.

module Test
  class Engine < Rails::Engine
    initializer "active_admin" do |app|
      ActiveAdmin.before_load do |app|
        app.load_paths << File.expand_path("../../../app/admin", __FILE__)
      end
    end
  end
end

OTHER TIPS

I would say that you gem file structure should probabily look someting like

your_gem
└── lib
    ├── admin
    │   └── some_model.rb
    └── your_gem.rb

and the file your_gem.rb should contain require 'admin/some_model'

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top