If you've been following along at home, you know that memoization was added to Rails 2.2 as a shortcut for a common idiom:

[sourcecode language='ruby']
def site_term_ids
@site_term_ids || = cached_terms.split.map
{ |term| Term.find_by_query(term).id }
end
[/sourcecode]

Memoization makes it possible to perform an expensive operation once, and then cache the results for future calls to the same property. What you may have missed, though, is that this isn't baked into Active Record; it's a separate part of Active Support. So if you're getting mystery errors about memoization not working, be sure you're including the right extension:

[sourcecode language='ruby']
class Site < ActiveRecord::Base
extend ActiveSupport::Memoizable

def site_term_ids
cached_terms.split.map
{ |term| Term.find_by_query(term).id }
end
memoize :site_term_ids

end
[/sourcecode]