SQL: Ordering with NULL values

First seen at Kabisa Blog: SQL: Ordering with NULL values This post tells you how to sort NULL values in a column to the bottom and sort the remaining non-NULL values. This is really great in combination with LEFT JOIN queries that may yield NULL values.

Rails: calculated column caching

Sometimes you’re working on a Rails project and you think: “hey! This should be easy!”. Well, most of the time it is. I’m working on a project that allows people to rate objects (what they really are doesn’t matter at all). I’m using the acts_as_rateable plugin which creates an extra database table containing all ratings. I also have a table with my objects. Using the plugin I’m now able to do the following: