Skip to content

Instantly share code, notes, and snippets.

@iamjohnford
iamjohnford / gist:c39e42d15e71702962ed111461b4b0c2
Created June 29, 2019 23:38
ActiveRecord::RecordNotUnique When Calling Active Storage attach
ActiveRecord::RecordNotUnique in MessagesController#upload
PG::UniqueViolation: ERROR: duplicate key value violates unique constraint "index_active_storage_attachments_uniqueness"
DETAIL: Key (record_type, record_id, name, blob_id)=(Message, 1, images, 1271) already exists.
Extracted source (around line #661):
#659 log(sql, name, binds, type_casted_binds) do
#660 ActiveSupport::Dependencies.interlock.permit_concurrent_loads do
*661 @connection.exec_params(sql, type_casted_binds)

Keybase proof

I hereby claim:

  • I am iamjohnford on github.
  • I am johnford (https://keybase.io/johnford) on keybase.
  • I have a public key ASDz6Wg9AXknuYYlBFPJBrjsQU6yzuowL2e_naoM50KiWAo

To claim this, I am signing this object: