Invalid single-table inheritance type: Admin is not a subclass of User

This error is bizarre. This error wasted my couple of hours; here is the detail



Here is the situation – I have used STI technique for models like Admin, VO, GO where all are derived from User model.

Lately I added ActiveAdmin plugin in my app and I was required to integrate it using the Admin model of course. For that purpose ActiveAdmin installer created a file called app/admin/admin.rb

Actual Reason

I suspect that, the similarity of filenames admin.rb might be the cause of the error. Because, the models and the ruby files in app/admin dir are lazy-loaded[loaded on need].

When I renamed the file app/admin/admin.rb to admins.rb ; then restarted the server, it started working back again.

Another way

The cause of this error is found to be the namespace collision. ActiveAdmin creates a module for namespaces (by default Admin). Rails could not find the Admin model but found Admin namespaced-module instead; this is what the error is saying. So, change the namespace like

# To set no namespace by default, use:
#   config.default_namespace = false
# Default:
config.default_namespace = :admins # instead of :admin