public
Created

  • Download Gist
find_or_create_helper.rb
Ruby
1 2 3 4
def find_or_create(factory, attributes)
klass = FactoryGirl.factory_by_name(factory).build_class
klass.where(attributes).first or create(factory, attributes)
end

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.