0

I am trying to extend the ActiveAdmin interface and add another reusable resource to the menu with a Rails plugin.

I have created a new full engine:

# Not mountable because it build up on ActiveAdmin
rails plugin new activeadmin-files --full     

Then I added a file to my engine under lib/activeadmin-files/admin/files.rb:

ActiveAdmin.register_page "Files" do
  menu :label => "File Management"

  content do
    para "Hello File Manager"
  end
end

I followed the description from the ActiveAdmin Wiki to add a resource to an engine. I modified engine.rb as follows:

module ActiveadminFiles
  class Engine < ::Rails::Engine
    initializer :files do
      ActiveAdmin.application.load_paths += Dir[File.dirname(__FILE__) + 'activeadmin-files/admin']
    end
  end
end

The only difference is that my engine is a full engine and the one on the wiki page is a mountable engine.

Problem: The page defined in files.rb does not appear when I open the ActiveAdmin interface. What am I missing here?

Community
  • 1
  • 1
halfdan
  • 33,545
  • 8
  • 78
  • 87

1 Answers1

0

This looks like it should work. The only reason I can think that it isn't working is if the initializer is not actually running on application startup.

Can you output some logging in the initializer block and make sure that the code is actually running?

Greg Bell
  • 374
  • 2
  • 5
  • The initializer is being executed.. For some reason I can't use the `test/dummy` app in the engine. `rails generate active_admin:install` adds some files to the app and then throws an `active_admin.rb:1:in '': uninitialized constant ActiveAdmin (NameError)` – halfdan Aug 23 '12 at 21:48