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

  • Home
  • SEARCH
  • 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 1052277
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T17:04:07+00:00 2026-05-16T17:04:07+00:00

I am just playing around with Ruby on Rails 3.0 with a simple message

  • 0

I am just playing around with Ruby on Rails 3.0 with a simple message board and found several issues with will_paginate.

The most pressing is that each time a new page is displayed a database query of every single post in the topic is performed.

As you can imagine, if you have a topic with 10,000+ posts this is very slow.

Is there a way to stop this odd behavior?

Show controller:

@posts=@topic.posts
@posts = Post.paginate @posts, :page => params[:page],:order => "post_number"

Model

cattr_reader :per_page 
@@per_page = 20

view

<%= will_paginate @posts %>
  • 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-16T17:04:08+00:00Added an answer on May 16, 2026 at 5:04 pm

    In your controller try:

    @posts = Post.paginate_by_topic_id @topic.id, :page => params[:page],:order => "post_number"
    

    Look at the example in the will_paginate docs

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just started playing around with the 960 CSS framework and found that it
I was just playing around with Rails 3 beta and noticed that link_to_function is
I'm just playing around with WPF and MVVM, and I have made a simple
I just started playing around with threading today and I ran into something that
I've just started playing around in Haskell. After years of Ruby, I got used
Just playing around with Rails 3.1 at the moment, and one issue I'm having
I was just playing around with the id() function & noticed that if you
I'm new to Ruby on Rails...I've been playing around with developing a social networking
I'm playing around with making a simple terminal-based game with Ruby, and I'm currently
Just playing around with the now released Silverlight 2.0. I'm trying to put a

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.