I use act_as_paranoid and friendly_id (5.0.1) in the model, and when I destroy the model and try to create a new one that will generate the same pool, I get:
ERROR: duplicate key value violates unique constraint "index_papers_on_slug"
I need to somehow get a code that checks if an already installed slug exists within all objects, not just not deleted ones.
How can I get friendly_id to use with_deletedwhen checking if slug exists. I should note that I also use traffic history, which can complicate the situation.
When I went deeper, I realized that since I am using history, slug is completely deleted when the object is just gently deleted:
DELETE FROM "friendly_id_slugs" WHERE "friendly_id_slugs"."id" = $1 [["id", 9423]]
So, I just need to figure out how to prevent this, and I should be fine, as it looks like the friendly_id code itself is already using it unscopedwhen trying to find a valid pool.
source
share