Skip to content

Updated ActiveRecord::Base.find_or_create_by for 2 attributes when 1 is n #1276

Closed
wants to merge 1 commit into from
Commits on May 24, 2011
  1. @jeremyf

    Updated ActiveRecord::Base.find_or_create_by for 2 attributes when 1 …

    jeremyf committed May 24, 2011
    …is nil
    
    Updated the find_or_create_by_foo_and_bar('hello') to process the find portion
    similar to find_by_foo_and_bar('hello').  In the original
    find_by_foo_and_bar('hello'), the resulting query was something like
    "foo = 'hello' AND bar IS NULL".  In the original
    find_or_create_by_foo_and_bar('hello'), the resulting query was something like
    "foo = 'hello'"
    
    This patch aligns those two methods expected behaviors on the "find" portion
    of the method call.
Something went wrong with that request. Please try again.