Report abuse

HasManyThroughAssociation has a performance problem where push and <<, etc., trigger a gratuitous load of the @target association. This is very punishing on a large association collection.

Part of the issue is that HasManyThroughAssociation#method_missing indirectly forces load_target to run, loading the association. This means that returning(), require, etc., and other valid methods not local to the class trigger object state change and database loads. The attached patch avoids calling returning() for this reason.