I've got several routes that point to a single controller action like this:
get '/elliptical-incline-motors', to: 'search#category_search'
get '/incline-ramp-wheels', to: 'search#category_search'
get '/elliptical-drive-belt', to: 'search#category_search'
get '/elliptical-batteries', to: 'search#category_search'
My query looks like this:
@products = Product.joins(category_model: {category_brand: :category}).where("categories.name = ? AND products.status = ?", category, "Viewable On Website & Backend").order(popularity: :desc).page(page).per(25)
If I am on the elliptical-batteries page (or any of the other pages that use the same controller action) and I select next page or a page number, the requested url is always the elliptical-incline-motors uri with my new page number. It looks like Kaminari is grabbing the first route because when I change this route in the route file the pagination get request changes accordingly. Is there a work around for this without chaning my current routing structure?
I think only one route is necessary, but you should send params to dispatch queries in action. Like that:
And in your controller:
I hope it will help you