A recent post on the StackOverflow beta (http://beta.stackoverflow.com/
questions/10808/ruby-mixins-and-calling-super-methods#11866 for those
who are on it) discusses a problem with chaining after_initialize
definitions from multiple mixin modules. The problem is that each
module must use alias_method_chain (or call super) to make sure the
other after_initialize calls are executed, but models don't define
after_initialize by default. The first module included can't chain to
the non-existent definition.
class Foo < ActiveRecord::Base
The solution is
I can see a counter-argument to putting this in core: if you're going
to include the mixin, you should be defining it yourself. But I'm not
convinced. I don't see any reason why there aren't default (empty)
implementations of every callback method. Doing so would obviate the
check during object creation, which can only be a good thing.