Depending on performance needs, you can also look at the counter_cache
option for the ActiveRecord association.
Your current approach has to query the child table to get the count,
which could be a performance hit on a big site.
Don't prematurely optimize though - it's just good to know about other
options in case the need arises.