Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7791525
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T21:54:49+00:00 2026-06-01T21:54:49+00:00

Am trying to do filtering part. Filtering means, when user selects some choices based

  • 0

Am trying to do filtering part. Filtering means, when user selects some choices based on that product details will be displayed. If user selects women (department) and men department it should display all the products which belongs to both women and men. To do this I am using sunspot and concatenating two objects. It is working fine. But when am trying to do pagination using Kaminari it works fine if user selects only one department like women.

If user selects both men and women then it is throwing an error like:

undefined method `current_page’ for Array

Am doing the above mentioned work like the following code.

deptids=["1" "2"]
deptids.each do |did|
    @search_res=ProductDetail.search do
        with :department_id, did                  
        paginate :page=>params[:page], :per_page=>15
    end
end

Please can any one tell that how to do pagination for array of objects using Kaminari Gem?

Please tell me how to do array of objects pagination using Kaminari or how to append two objects into one single object

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T21:54:51+00:00Added an answer on June 1, 2026 at 9:54 pm

    I solved this problem with the help of this Stackoverflow link.

    The code what i have changed is in product_details controller

    def index
        count=ProductDetail.count
        deptids=["1" "2"]
        deptids.each do |did|
            @search_res=ProductDetail.search do
                with :department_id, did    
                paginate :page=>1, :per_page=>count
            end
        end
        if @products.present?
            unless @products.kind_of?(Array)
              @products = @products.page(params[:page]).per(30)
            else
              @products = Kaminari.paginate_array(@products).page(params[:page]).per(30)
            end
        end
    end
    

    In view _index.html.erb

    <%= paginate @products, :remote=>true %> 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Am trying to do filtering part. Filtering means, when user selects some choices based
I am trying to perform some composition-based filtering on a large collection of strings
I am trying to build a collaborative filtering based Recommendation System as part of
I'm filtering some content on my website via country specific code, I'm trying to
I'm very new to SIMD/SSE and I'm trying to do some simple image filtering
I'm trying to create a bbcode filtering solution that works with both PHP and
I am trying to add some filtering to the application context file, which resides
I'm trying to write a generic filtering function that performs linear interpolation at a
I am trying to make a filtering where a user would search by last
I am trying to paginate some data from a model called D filtering results

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.