1
votes

I've tried installing ActiveAdmin into a rails app that already has an Admin model* and it all works, until I try to run any code (e.g. run specs, or run the rails server) which needs to access the Admin class -- then it fails as if the problem is with my Admin class:

foo/app/models/admin.rb:1:in `<top (required)>': Admin is not a class (TypeError)
from bar/.rvm/gems/ruby-1.9.2-p320/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251:in `require'

*In my case I used --skip-users so I could reuse my Admin model, but it happens whether you do this or not. It also happens if you do:

rails generate active_admin:install Admin

How can I get ActiveAdmin to coexist with a model (or other class) called Admin

1

1 Answers

4
votes

It took me a while to work this out (on a previous project I gave in and just renamed the model).

There have been some patches proposed, but actually there is a perfectly good config option that fixes this:

Edit the initializer at config/initializers/active_admin.rb so that the default_namespace is different (you could skip the default_namespace with config.default_namespace = false, but I haven't tried this).

I chose admin_ui for this:

 config.default_namespace = :admin_ui

There may be more subtlety for this so you can (if you want) keep the /admin/ route rather than have admin_ui but this was good enough for me -- the official docs on this are at http://activeadmin.info/docs/1-general-configuration.html#namespaces, but don't mention this reason to change the namespace.