redo ActiveRecordExt in Ruby1.9 for greater generality