0 Comments By Damon on Mar 04 in Rubyonrails and Releases.

So for anyone in the Rails community, you might have already read about and started using the Pagination module like I have for a number of months. Cooked in by default, it provides an easy and convenient way to implement paging within your web application. However, simplicity doesn't come without an expense. There have been numerous articles (e.g., Things You Shouldn't Be Doing in Rails) that mention how unscalable and inefficient using this functionality can be. Although seductive at first glance, developers should be very careful on how this is implemented. Above and beyond that, the Pagination module is also going to be extracted into a plugin in a future version of Rails.

Like I mentioned, I've been using the Rails pagination module for quite some time with no issues. Then again, the site isn't all that big and there isn't much to paginate for the most part. I also noticed that this module will be extracted into a plugin in a future version of Rails. With that in mind, I decided to investigate alternative ways to roll my own custom pagination.

After seeing what others in the community were recommending, I happened to stumble across the Faster Pagination in Rails article which discussed a plugin called paginating_find that overwrites the default find method in Rails if you specify the page parameters in the query. Perfect!

So since I was already re-factoring the code to use the new plugin, I figured I may as well try and improve the look and feel of the paging itself since I wasn't happy with that from the get go. It just so happens, that the Faster Pagination in Rails article itself describes how to create a helper method for creating Digg.com style paging into your website. Double-perfect!

After installing the plugin, creating the necessary helper method, and doing some custom stylesheet work, it wasn't long before I had the new paging system up and running. But wait, your Damon and you never get lucky on the first try. Yeah, isn't that the truth as was it this time around as well.

About 95% of this site uses the same paging framework. However, I also use the acts_as_ferret plugin to provide search capabilities on each section. To make ferret play nice with paging required some significant re-factoring. Ilya Grigorik to the rescue again! With his Ferret Pagination in Rails combined with a few of my custom modifications, I was able to get the paging functionality universal across all sections of the site.

 

With no further delay, introducing the new paging system. This should fix the inefficiencies of the default Pagination module and has a fresh look and feel with a Digg.com touch to it.

Current Rating: 4.0 rating from 1 vote

  • Current rating is 4
  •  
  •  
  •  
  •  
  •  

No Responses to "New Paging Required"

Comments are Closed

Name: (Required)
Website:
Comment:
Remember my info