This project is archived and is in readonly mode.

#1224 ✓committed
Ken Miller

find_or_create_by_ methods do not execute their block on first call

Reported by Ken Miller | October 16th, 2008 @ 02:08 AM | in 2.x

Because of the way find_or_create_by methods are autogenerated on first use, the initializer block is not properly passed on the very first invocation, though subsequent invocations work fine.

Attached patch includes a test and the fix, which is to explicitly capture and pass the block as an argument in method_missing.

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

People watching this ticket

Referenced by

Pages