Hi all,
In the current stable 2.3, ActiveRecord::Associations::AssociationProxy#method_missing calls yield () if a block is given, causing the block to always be evaluated in its calling context. However, in the case of instance_eval, correct behavior requires that the block be passed directly to the @target, rather than being evaluated inside a different block. Incidentally, this also simplifies the code slightly.
This patch is against the 2-3-stable branch.
Much appreciated if y'all would check it out! It's a very small patch and includes test cases.
Thanks, Mat