You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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!
The text was updated successfully, but these errors were encountered:
Seeing the same issue with ActiveStorage after upgrading to Rails 6.
Come to think about it, it probably is the right behavior, and for some reason up until Rails 6, deleting the model with attached storage just didn't trigger dependent destroy for some reason.
Hi -
I've got a Post model with using ActionText (
has_rich_text :body
) and I addedacts_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: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!
The text was updated successfully, but these errors were encountered: