Little success story

I got some free time lately, so I sat down trying to figure out how to make pagination of tagged entities. I’m using acts_as_taggable_on_steroids plugin for tagging and will_paginate for pagination of some standard queries.

Pagination plugin allows you to replace ‘find’ method with ‘paginate’ one:

Game.find(:all)
Game.paginate(:all, :page => 1)

Tagging plugin allows ‘tagged_with’ suffix to any ‘find’ method call:

Game.find_tagged_with('tsumego')

It’s easy to find out, that all I needed was:

Game.paginate_tagged_with('tsumego', :page => 1)

This is the power of dynamic languages. Pretty simple and really useful. All those small magic tricks makes writing software in RoR really exiting!

Leave a Reply