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

Kaminari and Collections #1056

Open
derekpovah opened this issue Apr 20, 2021 · 0 comments
Open

Kaminari and Collections #1056

derekpovah opened this issue Apr 20, 2021 · 0 comments

Comments

@derekpovah
Copy link

I'm leveraging Rails collections to generate pretty URLs for some Active Record scopes and I'm pointing all of them to a single controller action to keep my controllers dry:

resources :pass_applications do
  collection do
    get :approved, to: 'pass_applications#collection'
    get :submitted, to: 'pass_applications#collection'
    get :canceled, to: 'pass_applications#collection'
    get :denied, to: 'pass_applications#collection'
  end
  # ...
end
def collection
  @collection = request.path.split('/').last
  @pass_applications = PassApplication.send(@collection).page(params[:page])
  render :index, layout: 'user'
end

The Kaminari helpers generate links to whichever collection is at the top of the collection block and not current_page. If current_page is /pass_applications/submitted, I'd expect link_to_next_page to be /pass_applications/submitted?page=2, but it's actually /pass_applications/approved?page=2. All of the Kaminari helpers behave this way.

Am I trying to make Kaminari do something it wasn't designed to do or is this a bug?

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