outoftime
2009-Oct-22 15:35 UTC
Patch for correct instance_eval behavior for AssociationProxy
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. https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/3412-patch-correctly-handle-instance_eval-in-association-proxies#ticket-3412-2 Thanks, Mat