Released: Oct 28, 2009, Running time: 38 min
In this episode:
We add pagination using will_paginate to the search results fetched from Twitter.
Add to cart$5.00Released: Oct 28, 2009, Running time: 38 min
In this episode:
We add pagination using will_paginate to the search results fetched from Twitter.
Add to cart$5.00Find 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.
No comments yet