wangjohn/rails — pull request #2 by wangjohn (2013-03-01 06:28:51+00:00)
Title: Find() in associations now checks in-memory records before going to the database

This fixes issue https://github.com/rails/rails/issues/9470. The ```find()``` method on an association will now first check to see if any records exist in the association with the given ids before visiting the database. This prevents an unneeded database call if the records already exist in memory.

The new function scans the target of the association for the ids sent as inputs to ```find()```. The ids of the records that are found are removed from the ids which will be sent to the database.