Re: [Rails-core] Behavior of first_or_create

2012-07-25 Thread Matt Jones
On Jul 24, 2012, at 5:42 PM, Jon Leighton wrote: On 24/07/12 21:29, Matt Jones wrote: Nope, that's not exactly what I observed; I'll try again. That code *does* call the create correctly, if there are no users with the correct first_name. The confusing part to me was that it wasn't

[Rails-core] Behavior of first_or_create

2012-07-24 Thread Matt Jones
I just ran across a weird glitch (IMHO) in find_or_create. The arguments passed to it are *not* added to the conditions for the 'first' part. This is odd, given that it's intended to replace find_or_create_by_* methods, which *did* use the specified values as conditions. I'm unsure on whether

Re: [Rails-core] Behavior of first_or_create

2012-07-24 Thread Andrés Mejía
I would definitely expect User.where(:first_name = 'Scarlett').first_or_create(:last_name = O'Hara) to call User.create(:first_name = 'Scarlett', :last_name = O'Hara) if that's not what's happening then I think it's a bug and should be fixed. Matt, do you have a minimal app that shows the

Re: [Rails-core] Behavior of first_or_create

2012-07-24 Thread Matt Jones
On Jul 24, 2012, at 4:04 PM, Andrés Mejía wrote: I would definitely expect User.where(:first_name = 'Scarlett').first_or_create(:last_name = O'Hara) to call User.create(:first_name = 'Scarlett', :last_name = O'Hara) if that's not what's happening then I think it's a bug and should

Re: [Rails-core] Behavior of first_or_create

2012-07-24 Thread Jon Leighton
On 24/07/12 21:29, Matt Jones wrote: On Jul 24, 2012, at 4:04 PM, Andrés Mejía wrote: I would definitely expect User.where(:first_name = 'Scarlett').first_or_create(:last_name = O'Hara) to call User.create(:first_name = 'Scarlett', :last_name = O'Hara) if that's not what's happening then