Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Collection is not a paginated scope" error when adding a before_filter #1212

Closed
JohnMerlino1 opened this issue Apr 6, 2012 · 3 comments
Closed

Comments

@JohnMerlino1
Copy link

Hey all,

I am trying to add a before_filter to the index action so I can set the instance variable in the before_filter and hopefully when the index action gets called, it will check if the var is already set. And then if it is, use that rather than the activeadmin defaults:

ActiveAdmin.register Account do
//... (code)

controller do
  before_filter :checkviews, :only => :index

  def checkviews
    if params[:q] && params[:q][:ancestry_eq]
      @accounts = Account.ancestry_scoper(Account.find_by_id(params[:q][:ancestry_eq]))
    end
  end
end

Problem is I get this error message:

Collection is not a paginated scope. Set collection.page(params[:page]).per(10) before calling :paginated_collection.
@latortuga
Copy link
Contributor

If you are setting the instance collection variable manually, you'll need to paginate it manually, as stated in the error. ActiveAdmin uses pagination helpers on the index page.

@j-manu
Copy link
Contributor

j-manu commented Apr 10, 2012

@j-manu j-manu closed this as completed May 7, 2012
@belt
Copy link

belt commented Jul 17, 2012

Certain models may be named very close to what appears to be reserved words e.g. core, or page.
These models tend to trigger this issue too. Likely, you stumbled upon this issue via a google-search.

See #959 for an example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants