Rails 3.2 ActiveAdmin 'Collection is not a paginated area.' mistake

I am developing an application using Rails 3.2 and ActiveAdmin 0.4.4. I have a model called Teaser (/app/models/teaser.rb):

class Teaser < ActiveRecord::Base attr_accessible :img, :name, :url validates :img, :name, :presence => true mount_uploader :img, TeaserUploader end 

And I added ActiveAdmin to it (/app/admin/teaser.rb):

 # encoding: UTF-8 ActiveAdmin.register Teaser do form do |f| f.inputs "Teaser" do f.input :name, :label => '' f.input :url, :label => '' f.input :img, :as => :file, :label => '' end f.buttons end end 

Now, when I go to 'http: // localhost: 3000 / admin / teasers', I get the following error:

Mapping C: /RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activeadmin-0.4.4/app/views/active_admin/resource/index.html.arb where line # 1 is raised: Collection not is a paginated area. Set up collection.page (params [: page]). Per (10) before the call: paginated_collection.

I get the same error when testing my application on Linux (Ubuntu 12.04).

I can solve this problem this way (/app/admin/teaser.rb):

 # encoding: UTF-8 ActiveAdmin.register Teaser, :as => 'Somename' do 

But if I use this method, I cannot translate this model using /app/config/locales/XX.yml

All other models work correctly.

+7
source share
7 answers

In some cases, all you have to do is change the model label in active admin

Example

Breaks

 ActiveAdmin.register Stage do 

WORKS

 ActiveAdmin.register Stage, as: "Opportunity Stage" do 

In the same case, for the Page model

Update: May 30

I ran into this problem again, having a model like

ActiveAdmin.register PageRedirects do

and in application_controller.rb I had this:

 before_filter :abc def abc @page_redirects = ... end 

This method overrides @page_redirects from the active admin controller, I think.

+8
source

Here is the solution (/app/models/teaser.rb)

 collection_action :index, :method => :get do scope = Teaser.scoped @collection = scope.page() if params[:q].blank? @search = scope.metasearch(clean_search_params(params[:q])) end 
+5
source

Just improving the answer ... I had problems using active admin filters, so I had to change the code a bit. Now it works for me.

 collection_action :index, :method => :get do scope = Teaser.scoped @search = scope.metasearch(clean_search_params(params[:q])) @collection = @search.page() end 
+2
source

You may have a variable with the same name as the controller that is conflicting. Perhaps in your application application_controller.rb?

+2
source

None of the answers worked for me in rails 4.1

The github issue discussion reveals that this is because the active administrator inherits the controller application .
Therefore, to answer this question, I assume that the error is caused by the assignment of some @teasers collection in the application controller.

+1
source

Can you rename the resource name on the active admin page, for example

 ActiveAdmin.register Teaser, as: "Some other name" do 

This solved my problem.

I think this is due to a resource name conflict.

0
source

Adding a default scope to the active administrator solved the problem for me.

 ActiveAdmin.register StaticPage, as: 'Static Page' do scope :all, default: true # ... end 
0
source

All Articles