2
votes

Im trying to mount rails active admin gem within a mountable engine, but getting stuck with the following error when I run the dummy app server --

     /.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.1/lib/active_support/file_update_checker.rb:25:in `stat': No such file or directory - /mycode/testingengine/app/admin (Errno::ENOENT)
from /.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.1/lib/active_support/file_update_checker.rb:25:in `block in updated_at'
from /.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.1/lib/active_support/file_update_checker.rb:25:in `map'
from /.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.1/lib/active_support/file_update_checker.rb:25:in `updated_at'
from /.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.1/lib/active_support/file_update_checker.rb:29:in `execute_if_updated'
from /.rvm/gems/ruby-1.9.2-p290/gems/activeadmin-0.3.3/lib/active_admin/reloader.rb:22:in `block in attach!'
from /.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.1/lib/active_support/callbacks.rb:404:in `_run_prepare_callbacks'
from /.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.1/lib/active_support/callbacks.rb:81:in `run_callbacks'
from /.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.1.1/lib/action_dispatch/middleware/reloader.rb:46:in `prepare!'
from /.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.1/lib/rails/application/finisher.rb:41:in `block in <module:Finisher>'
from /.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.1/lib/rails/initializable.rb:30:in `instance_exec'
from /.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.1/lib/rails/initializable.rb:30:in `run'
from /.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.1/lib/rails/initializable.rb:55:in `block in run_initializers'
from /.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.1/lib/rails/initializable.rb:54:in `each'
from /.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.1/lib/rails/initializable.rb:54:in `run_initializers'
from /.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.1/lib/rails/application.rb:96:in `initialize!'
from /.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.1/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /mycode/testingengine/config/environment.rb:5:in `<top (required)>'
from /.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:240:in `require'
from /.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:240:in `block in require'
from /.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:223:in `block in load_dependency'
from /.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:640:in `new_constants_in'
from /.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:223:in `load_dependency'
from /.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:240:in `require'
from /.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.1/lib/rails/application.rb:83:in `require_environment!'
from /.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.1/lib/rails/commands.rb:22:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'

Anyone have any idea how to fix this? I ran the rails g active_admin:install in the parent mountable engine directory, and the folder /mycode/testingengine/app/admin does exist with the default dashboard file, so Im not sure where to go from here. Any help much appreciated!

2

2 Answers

2
votes

Finally figured it out. In your ActiveAdmin.setup initalizer block add the following.

    config.load_paths.delete_at(0)
    config.load_paths << "#{Cms::Engine.root}/app/admin/"

Be sure to replace Cms with the name of your engine. Now it wont try to load activeadmin from the app using your engines folder.

1
votes

If ActiveAdmin is configured in your parent engine, and don't want to clutter the configuration in the parent app with references to a child app, you can set the ActiveAdmin load page in the mountable engine:

module YourEngine
  class Engine < ::Rails::Engine

    # ...

    initializer :divery do |app|
      ActiveAdmin.application.load_paths << File.join(config.root, 'lib/admin')
    end

    # ...

  end
end

Note that it's important that your ActiveAdmin resources are not defined in app/, all admin resources should be defined in lib.