A platform for community discussion. Free, open, simple.
Add Rails 6 note here
Sam57d04200a1aa
diff --git a/lib/freedom_patches/active_record_base.rb b/lib/freedom_patches/active_record_base.rbindex 7be646cde64..bcce2b39b97 100644--- a/lib/freedom_patches/active_record_base.rb+++ b/lib/freedom_patches/active_record_base.rb@@ -3,6 +3,16 @@ class ActiveRecord::Base# Handle PG::UniqueViolation as well due to concurrency# find_or_create does find_by(hash) || create!(hash)# in some cases find will not find and multiple creates will be called+ #+ # note: Rails 6 has: https://github.com/rails/rails/blob/c83e30da27eafde79164ecb376e8a28ccc8d841f/activerecord/lib/active_record/relation.rb#L171-L201+ # This means that in Rails 6 we would either use:+ #+ # create_or_find_by! (if we are generally creating)+ #+ # OR+ #+ # find_by(hash) || create_or_find_by(hash) (if we are generally finding)+ #def self.find_or_create_by_safe!(hash)beginfind_or_create_by!(hash)