-
Type: Bug
-
Resolution: Fixed
-
Priority: Unknown
-
Affects Version/s: None
-
Component/s: None
-
None
PR: https://github.com/mongodb/mongoid/pull/5012
Since #4817 find can take a block, however this is not used when a has many relation proxy is used. This is a simple change to allow the block to be passed through to the criteria.
Example:
class Widget include Mongoid::Document has_many :screws def find_flat_screw screws.find { |screw| screw.head == 'flat' } end end
The find method above will currently return an empty set incorrectly, instead of the first item in the has_many collection