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 7779429
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T18:38:27+00:00 2026-06-01T18:38:27+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 concatenating two objects. It is working fine. But when am trying to do pagination then it is throwing an error like:

undefined method `current_page’ for Array

I want to concatenate two ActiveRecord objects and result should be in object of same active record only. Please tell me how to do this.

Now what am trying is:

@products += @prods

EDIT

deptids=["1" "2"]
deptids.each do |did|
    @prods=ProductDetail.where("department_id=?",did)
    if !(@products.nil?)
        @products += @prods
    else
        @products=@prods
    end
end
  • 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-01T18:38:29+00:00Added an answer on June 1, 2026 at 6:38 pm

    After Googling i came to know that problem is in pagination since am getting undefined method current_page for Array. Therefore I used kaminari paginate array for pagination and my problem is fixed. For Kaminari paginate array i refered this stackoverflow link.

    I have changed my code like this:

    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.nil?)
            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
    
    • 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.