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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T06:02:22+00:00 2026-05-20T06:02:22+00:00

Rails 2.3.5 / Will_Paginate Gem 2.3.15 I have a page section where a user

  • 0

Rails 2.3.5 / Will_Paginate Gem 2.3.15

I have a page section where a user can select how many items per page to display (with an ‘all’ choice). I don’t like having ‘all’ in there but each item in the list has a checkbox so that bulk operations can be performed against the listed items (a user couldn’t select all items the query would return if the items are broken out into pages).

I haven’t found an answer looking around, but is there a way to set the :per_page option to ‘all’? I temporarily just put in a jumbo number (1000000) as a work-around. Is that the only way to do it?

I thought about just replacing the paginate_by_sql condition with a find_by_sql, but then in the view I’d have to add in logic to not write the “<%= will_paginate @items%>”

    if cookies[:items_per_page]
      if cookies[:items_per_page] == 'ALL'
        @items =  Item.paginate_by_sql(sql, :page => params[:page], :per_page => 1000000)
      elsif %w(10 20 30 40 50 75 100).any? {|str| cookies[:items_per_page].include? str}
        @items =  Item.paginate_by_sql(sql, :page => params[:page], :per_page => cookies[:items_per_page].to_i)
      else #cookie doesn't contain a valid choice, default to '10'
        @items =  Item.paginate_by_sql(sql, :page => params[:page], :per_page => 10)
      end
    else #cookie doesn't exist, default to '10'
      @items =  Item.paginate_by_sql(sql, :page => params[:page], :per_page => 10)
    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-05-20T06:02:23+00:00Added an answer on May 20, 2026 at 6:02 am
    Item.paginate_by_sql(sql, :page => params[:page], :per_page => Item.count)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using the will_paginate gem for my Rails project and it's working beautifully. Unfortunately,
In my Rails application I want to use the will_paginate gem to paginate on
Am using below specified gem acts-as-taggable-on(2.2.2) will_paginate(3.0.2) rails(3.0.3) ruby 1.8.7 i tried to use
I have used the rails will paginate gem for pagination.I have a drop down
I'm using the Rails 3 plugin Will_Paginate and have been using the following tutorial
Ruby on Rails controllers will automatically convert parameters to an array if they have
I have a Rails app that will post some data to another Rails app.
I'm using the Rails3 beta, will_paginate gem, and the geokit gem & plugin. As
I have built a blog application w/ ruby on rails and I am trying
Ive been stuck for a while now in the rails tutorial. Im in section

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.