-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
-
None
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?