We found this behavior in 2.1.0, so it would be great to have it
backported to 2.1.x, but I haven't tried the patch against the that
line.  Looks like it might work.

K

On Oct 24, 12:38 pm, "Michael Koziarski" <[EMAIL PROTECTED]>
wrote:
> On Fri, Oct 24, 2008 at 6:32 PM, Ken Miller <[EMAIL PROTECTED]> wrote:
>
> > when you use a find_or_create_ automatic method with an initializer
> > block, the block isn't called on the first run, but is called on
> > subsequent runs:
>
> > u = User.find_or_create_by_name('bob') { |new_user| new_user.password
> > = '1234' }
> > u.name
> >>> "bob"
> > u.password
> >>> nil
>
> > u2 = User.find_or_create_by_name('billy') { |new_user|
> > new_user.password = '1234' }
> > u2.name
> >>> 'billy'
> > u2.password
> >>> '1234'
>
> > This appears to have been around for a while.
>
> > Bug filed (with patch) here:
>
> >http://rails.lighthouseapp.com/projects/8994/tickets/1224-find_or_cre...
>
> Applied, nice catch.
>
> If it needs backporting to any other branches, let us know.
>
>
>
> --
> Cheers
>
> Koz
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to