Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating deleted_at to nil before deletion to database #452

Open
yllihv27 opened this issue Sep 6, 2018 · 1 comment
Open

Updating deleted_at to nil before deletion to database #452

yllihv27 opened this issue Sep 6, 2018 · 1 comment
Labels

Comments

@yllihv27
Copy link

yllihv27 commented Sep 6, 2018

When I call really_destroy! I expect it to directly remove the record from database but instead it updates the deleted_at then remove it from the database.

I believe there's no need to update the data before deleting it.

here are the logs

User Update (0.6ms) UPDATE "users" SET "deleted_at" = $1, "updated_at" = $2 WHERE "users"."id" = $3 [["deleted_at", "2018-09-06 05:24:19.366120"], ["updated_at", "2018-09-
06 05:24:19.366179"], ["id", 15]]
↳ app/use_cases/use_case/user/deactivate.rb:11
User Destroy (1.4ms) DELETE FROM "users" WHERE "users"."id" = $1 [["id", 15]]

@fabriciofreitag
Copy link

fabriciofreitag commented May 17, 2021

this is specially troublesome when you have a has_many :foos, dependent: :restrict_with_error
once you use really_destroy! it'll fail but the timestamp will be wrongfully touched (just happened to me)
as an ugly workaround I'm first checking:

if bar.destroy
  bar.really_destroy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants