Ruby select number of records to view

Using Ruby on Rails 1.8

I need to filter the number of records being displayed on a page.  A select box gives several choices of the number to be displayed.  Once the value is chosen, the page will be updated.

How do I implement this using ruby on rails?
lcorAsked:
Who is Participating?
 
eksatxConnect With a Mentor Commented:
I recommend using one of the pagination gems

(will_paginate is still very popular).

It lets you put something like this in your controller:

@things = Thing.paginate(:all, :page => params[:page],

:per_page => 10)

Now, you want to have the user select how many records to

show per page.  Therefore, you should add a select to your

view that sets a parameter called per_page.

You then just need to change the line in your controller

to this:

@things = Thing.paginate(:all, :page => params[:page],

:per_page => params[:per_page])
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.