Skip to content

Doesn't soft delete ActionText #497

Open
@stewartjohnson

Description

@stewartjohnson

Hi -

I've got a Post model with using ActionText (has_rich_text :body) and I added acts_as_paranoid to it for soft deletes. It works fine on the Post model itself, but the rich text field is automatically deleted regardless. Here's the server log as I deleted a post:

Started DELETE "/posts/16" for 127.0.0.1 at 2020-07-12 21:44:15 +1000
Processing by PostsController#destroy as HTML
  Parameters: {"authenticity_token"=>"qG0f5iaUxM8BNJOHaPkr/xWEeP6AG72yPvy/e4ZFRDRzeIOSCA2QERC6lMYB27rtQickNiDWlZPcBjm70orHwg==", "id"=>"16"}
  User Load (0.3ms)  SELECT `users`.* FROM `users` WHERE `users`.`id` = 2 ORDER BY `users`.`id` ASC LIMIT 1
  Post Load (0.1ms)  SELECT `posts`.* FROM `posts` WHERE `posts`.`deleted_at` IS NULL AND `posts`.`id` = 16 LIMIT 1
  ↳ app/controllers/posts_controller.rb:50:in `set_post'
  Discussion Load (0.2ms)  SELECT `discussions`.* FROM `discussions` WHERE `discussions`.`id` = 1 LIMIT 1
  ↳ app/controllers/posts_controller.rb:52:in `set_post'
   (0.2ms)  BEGIN
  ↳ app/controllers/posts_controller.rb:40:in `destroy'
  ActionText::RichText Load (0.2ms)  SELECT `action_text_rich_texts`.* FROM `action_text_rich_texts` WHERE `action_text_rich_texts`.`record_id` = 16 AND `action_text_rich_texts`.`record_type` = 'Post' AND `action_text_rich_texts`.`name` = 'body' LIMIT 1
  ↳ app/controllers/posts_controller.rb:40:in `destroy'
  ActiveStorage::Attachment Load (0.3ms)  SELECT `active_storage_attachments`.* FROM `active_storage_attachments` WHERE `active_storage_attachments`.`record_id` = 16 AND `active_storage_attachments`.`record_type` = 'ActionText::RichText' AND `active_storage_attachments`.`name` = 'embeds'
  ↳ app/controllers/posts_controller.rb:40:in `destroy'
  ActionText::RichText Destroy (2.2ms)  DELETE FROM `action_text_rich_texts` WHERE `action_text_rich_texts`.`id` = 16
  ↳ app/controllers/posts_controller.rb:40:in `destroy'
  Post Update (0.3ms)  UPDATE `posts` SET `posts`.`deleted_at` = '2020-07-12 11:44:16', `posts`.`updated_at` = '2020-07-12 11:44:16.019582' WHERE `posts`.`id` = 16
  ↳ app/controllers/posts_controller.rb:40:in `destroy'
  Post Update (0.2ms)  UPDATE `posts` SET `posts`.`updated_at` = '2020-07-12 11:44:16.019177' WHERE `posts`.`id` = 16
  ↳ app/controllers/posts_controller.rb:40:in `destroy'
   (0.9ms)  COMMIT
  ↳ app/controllers/posts_controller.rb:40:in `destroy'
Redirected to http://localhost:3000/discussions/1
Completed 302 Found in 28ms (ActiveRecord: 4.8ms | Allocations: 25600)

You can see the update of the post model deleted_at column, but there's also the SQL for deleting from the ActionText tables.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions