全てのモデルに before_find を追加するには
下記のようなに,抽象モデルを上位に作り,それを継承する感じにする.
class Human < ActiveRecord::Base self.abstract_class = true class << self def find(*params) puts "before_find" super end end end class Person < Human end
すると,
>> Person.find(:all) before_find => [#<Person id: 1....
などとなる.データベース実体のない抽象モデルを作ることで,ActiveRecordに手を加えなくともテーブル分割や分散データベース処理などできそうです.