Blog posts from
January February March April May June July August September October November December // 2009
January February March April May June July August September October November December // 2011
January February March April May June July August September October November December // 2015
This is really useful if you want to break apart a series of objects on something like a date-time field, which doesn't quantize exactly to integer values (on all databases) and so can't be handled using non-exclusive ranges without overlaps from values exactly on the boundary.
I've extracted out the code I was using to lazily load large BLOB/TEXT columns in one of my projects, tidied it up to take advantage of a refactoring in Rails 2.2.2 (cheers Koz) and improve its semantics, and released it as the columns_on_demand plugin.
This plugin is useful if you have large columns on your models but find that you don't need those columns to do most of the things you do with the records. In this case you incur a substantial penalty in memory use (in your appservers) for all the unnecessarily-loaded data, plus a noticable penalty on your database server as it has to do extra seeks to get the off-page large data. With this plugin you can essentially transparently move those columns out so that they are loaded only when they're actually required, without having to manually split your model or put in :select options everywhere.
All you have to do is invoke it in your model:
class MyModel < ActiveRecord::Base columns_on_demand end
And if will lazily load the model's BLOB and TEXT columns from that point on. You can also specify which columns you want (of course, this works with all types of columns, not just :binary/:text):
class MyUpload < ActiveRecord::Base columns_on_demand :file_data, :processing_log end
I heart the When can I use page, which is basically a filterable inverted index for all the current-gen and next-gen browser features we web devs are waiting for are available in all the big browsers, so you can find out at what point you can use them on their own, and how much sooner you could get there with shims and workarounds. Very handy.