gregbell/active_admin — Issue #705: Can't view models using STI in development env
Author: ryanwilliams
Created: 2011-10-31 05:58:13+00:00
State: open

When a model uses STI, the subclasses can't be viewed after classes have been reloaded by Rails.

```ruby
# models/primate.rb
class Primate < ActiveRecord::Base
end

# models/monkey.rb
class Monkey < Primate
end

# admin/monkey.rb
ActiveAdmin.register Monkey do
end
```

If the dev server is restarted and you immediately hit http://localhost:3000/admin/monkeys/1 it will work fine, but if you then refresh the browser you will see:

> undefined method `active_admin_comments' for #\

It appears that the `register` event doesn't fire after Rails reloads the classes; so the `has_many :active_admin_comments` is never reapplied to STI subclasses.