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

Allowing for out_of_bounds? code to be handled consistently #166

Open
zdennis opened this issue Aug 22, 2011 · 0 comments
Open

Allowing for out_of_bounds? code to be handled consistently #166

zdennis opened this issue Aug 22, 2011 · 0 comments

Comments

@zdennis
Copy link

zdennis commented Aug 22, 2011

It would be nice to allow a way to handle out of bounds paging in a consistent way. Right now it's up to the calling code to call #out_of_bounds? and then to handle it on a case-by-case basis.

My scenario is that I want to send the person to page #1 if they happen to pick a per_page and page combination that is no longer valid:

class ApplicationController
  rescue_from WillPaginate::OutOfBoundsException do
    redirect_to params.merge(:page => 1)
  end
end

class MyController < ApplicationController
  def index
    @things = MyModel.paginate!(...)
  end
end

This would work across controllers (or views) because you wouldn't need to know about what was being paginated on, just that you needed to redirect back to page 1. Thoughts?

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

1 participant