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 be fixed. > Matt, do you have a minimal app that shows the problem? I would like to write > a test case for Rails that shows this strange behavior.
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 quite the same as this: User.where(:first_name => 'Scarlett').find_or_create_by_last_name("O'Hara") The latter includes a condition on last_name in the find, where the former does not. Given that the dynamic form is deprecated (targeted for removal in 4.1 - see active_record_deprecated_finders for details), it's worth either matching the old behavior or clearly documenting the difference to avoid confused upgraders. --Matt Jones -- 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 rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.