Reputation: 2564
I'm working on a small rails engine with I have turned into a gem. In order to manage the database I want to use ActiveAdmin.
I've added ActiveAdmin to my list of gem dependencies, and when I install the gem in my application I copy the active_admin initializer to config/initializers/ in the project which is using the gem.
However - for some reason this makes the application fail with the error:
uninitialized constant ActiveAdmin
If I add "activeadmin" to the projects Gemfile it run great - but that's wrong and I don't understand why I need to do that. I want my gem to be as isolated as possible.
Any help is welcome.
Upvotes: 1
Views: 1055
Reputation: 1127
Is MyModule::Admin your class? What is its path in gem? If it is not in app/ dir you might need to add the following to lib/my_module.rb
module MyModule extend ActiveSupport::Autoload autoload :Admin end
Upvotes: 0
Reputation: 1127
You might need to manually require activeadmin from your gem's railtie (Rails 3.x) or initializer (Rails 2.x). Also it might be wise to move your config/initializers/active_admin.rb to engine as well. Something like this for Rails 3.x (put it into lib/my_gem/engine.rb)
require 'activeadmin'
class MyGem::Engine < Rails::Engine
initializer do
# Do the same what you did in config/initializers/ of rails project
end
end
Upvotes: 2