ActsAsParanoid / acts_as_paranoid

ActiveRecord plugin allowing you to hide and restore records without actually deleting them.
MIT License
1.47k stars 192 forks source link

Calling delete then recover on the same object doesn't recover has_many/dependent relationships #253

Open catpreneur opened 3 years ago

catpreneur commented 3 years ago

Using rails 6.0 e.g.

class Post
  acts_as_paranoid
  has_many :comments, dependent: :destroy
end

class Comments
  acts_as_paranoid
  belongs_to :post
end

post = Post.find 1
post.destroy # safe deletes the post and the comment(s)
post.recover # recovers the post, but the comment(s) are still deleted

# if, instead, we simply fetch a new Post object and try calling recover it'll work
post_2 = Post.find 1
post_2.recover # recovers all comments
turnon commented 2 years ago

And the version of this gem ?

catpreneur commented 2 years ago

@turnon 0.7.3