Rails: NoMethodError in Admin::FooController
Appearance
Problem
An ActiveAdmin url `admin/bars/1/foos' stops with this error message:
NoMethodError in Admin::FooController#index undefined method `find' for nil:NilClass
where the model looks like this:
ActiveAdmin.register Foo do
belongs_to :bar
endEnvironment
- rails-2.1.0
- activeadmin-0.6.3
Solution
Manually specify the parent class:
ActiveAdmin.register Foo do
belongs_to :bar, parent_class: Bar
endSee also: https://github.com/activeadmin/activeadmin/issues/2518