mongoid/mongoid — Issue #1712: find_or_create_by doesn't call &block, in case it does "find"
Author: Gurpartap
Created: 2012-02-13 10:23:07+00:00
State: open

This feature was added in https://github.com/mongoid/mongoid/pull/678

`X.find_or_initialize_by(a: a, b: b, c: c) do |x|
puts x
end`

It only runs through the block on initialize (or create, if find_or_create_by is used).

The related code in finders.rb is

`def find_or(method, attrs = {}, &block)
first(:conditions => attrs) || send(method, attrs, &block)
end`

Shouldn't the block variable pass on to the finder as well?