after_find callback broken after upgrade to rails3


In an app that was working flawlessly in Rails 2.3.8 i have the
following class method:

    def self.encode(*attr_names)
      encoder =
      before_save encoder
      after_save encoder
      after_find encoder
      define_method(:after_find) { } # defining here, since there's
only alias in the Encoder class itself

This method references the Encoder class. Here is it:

    class Encoder
      include Encodings
      def initialize(attrs_to_manage) # We're passed a list of
attributes that should be stored encoded in the database
        @attrs_to_manage = attrs_to_manage
      def before_save(model) # Before saving or updating, encode the
attributes to their original encoding
        @attrs_to_manage.each do |field|
          model[field] = to_orig_encod(model[field])
      def after_save(model) # After saving, encode them back to utf8
        @attrs_to_manage.each do |field|
          model[field] = to_utf8(model[field])
      alias_method :after_find, :after_save # Do the same after
finding an existing record

Before the upgrade to rails3 all the callbacks (before_save,
after_save, after_find) worked fine. After the upgrade *before_save*
and *after_save* still work, but *after_find* does not and I get the
following deprecation warning in my log:

    DEPRECATION WARNING: Base#after_find has been deprecated, please
use Base.after_find :method instead

I'm uncertain how to change my code in order to re-enable the
functionality of the after_find callback. I tried a few simple
alternations with no success and the rails API documentation on this
callback is very limited and without examples of implementation.

Any help appreciated, thanks in advance!

The idea here is in Rails 3, within ActiveRecord::Base, you should not
define the method after_find such as:

def after_find

Instead, you should do:

after_find :my_after_find_method

def my_after_find_method

Somehow they failed to mention such a simple thing in the API Document.