1

I'm sure the answer to this is out there, but I can't seem to find it. So, I apologize in advance.

I had a perfectly functioning very basic Active Admin interface managing a handful of simple models.

Then, I went to add a couple of models that have has_many relationships and broke most of the pages.

AA now throws:

undefined method `captures' for nil:NilClass

when visiting the Sports tab created by:

rails g active_admin:resource sport

The model I tried to add is:

class Sport < ActiveRecord::Base
  attr_accessible :name

  has_many :matches
  accepts_nested_attributes_for :matches
end

My AA sport.rb is empty:

ActiveAdmin.register Sport do

end

[Edit]

For what it's worth, I've discovered that the problem is in the filters panel of the index page in AA. If I disable filters with the code below, everything works fine.

ActiveAdmin.register Sport do
    config.filters = false
end

Is there anything obviously wrong? I can post the stack trace and other model definitions if needed.

Thanks!

Greg

4

1 に答える 1

0

index アクションを次のように書き直してみてください。

ActiveAdmin.register Sport do
  controller do
    def index
      @search = Sport.ransack(params[:q])
      @sports = @search.result(distinct: true).page(params[:page]).per(10).order("created_at desc")
    end
  end
end

https://github.com/ernie/ransack/issues/107

于 2013-09-12T13:58:53.460 に答える