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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:22:27+00:00 2026-05-26T12:22:27+00:00

I want to pull 5 records at a time into the view (I’m using

  • 0

I want to pull 5 records at a time into the view (I’m using rails 2.3.8).

I am using will_paginate, and it’s working great but:

I want to send those results to the view, 5 records at a time, then add a div, then loop through until they’re all shown.

I tried using find_in_batches, but I don’t know how to access the objects it’s returning. Can I use #{}?

I know there’s .first and .last methods but is there any such thing as .second, .third, .fourth, etc?

  • 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-05-26T12:22:28+00:00Added an answer on May 26, 2026 at 12:22 pm

    You have an example for find_in_batches in the documentation:

    Person.find_in_batches(:conditions => "age > 21", :batch_size => 5) do |group|
      sleep(50) # Make sure it doesn't get too crowded in there!
      group.each { |person| person.party_all_night! }
    end
    

    This may not be the solution you’re looking for, though. If you have 5000 records, this will issue 1000 database queries.

    A better solution would be using each_slice, this method will fetch all records in one database query and split the result set afterwards:

    Person.find(:all, :conditions => "age > 21").each_slice(5) do |group|
      group.each { |person| person.party_all_night! }
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to pull all records except the TOP 10 in my statement but
I want to pull out duplicate records in a MySQL Database. This can be
I have a remote monotone repos I want to pull from, but I really
I have a multidocument application. I want to pull data from each of those
In writing select statements in mySQL, if I want to pull records where a
I want to pull out the records that have a date that is LIKE
I'm using JQuery UI Autocomplete to pull records from a caller database. This works
I have two tables, jos_eimcart_customers_addresses and jos_eimcart_customers. I want to pull all records from
I want to pull a series of relationships out of xml files and transform
I have a div with width 600 px. I want to pull the images

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.