Jump to content

Rails: NoMethodError in Admin::FooController

From FVue

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
end

Environment

  • rails-2.1.0
  • activeadmin-0.6.3

Solution

Manually specify the parent class:

ActiveAdmin.register Foo do
  belongs_to :bar, parent_class: Bar
end

See also: https://github.com/activeadmin/activeadmin/issues/2518