Episode 10 - The Dashboard, part 2 - pagination


Click on image above for a preview

Released: Oct 28, 2009, Running time: 38 min

In this episode:

We add pagination using will_paginate to the search results fetched from Twitter.

Tags: cucumber, rspec, twitter

Add to cart$5.00
  • Share

Find out how you write features and specs for paginating an ActiveRecord model.

In episode 9 we started displaying the search results fetched from Twitter on the dashboard. As we ran some manual fetches from the console, it became obvious we need pagination. We add this using the excellent will_paginate gem.

We go through writing a “pagination” feature where we check that only the required models make it into the view and when we go to the next page, the next models are fetched.

Next, we go into the inner cycle and spec the BrandsController, specifying that it should call “paginate” on our model. We screw it up at first, but get it eventually… :)

The will_paginate gem handles most of the pagination logic inside the models, but we still need to handle the order of our search results in our application code.


  • Vlcsnap-2009-10-28-12h45m53s225
  • Vlcsnap-2009-10-28-12h46m05s86
  • Vlcsnap-2009-10-28-12h46m41s158
  • Vlcsnap-2009-10-28-12h46m53s0
  • Vlcsnap-2009-10-28-12h46m57s72
  • Vlcsnap-2009-10-28-12h47m10s226
  • Vlcsnap-2009-10-28-12h47m37s229

No comments yet

Commenting is disabled.