ActsAsParanoid / acts_as_paranoid

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

recover! method raises validation error even if record is valid. Using recover works properly #279

Open rohitjoshixyz opened 2 years ago

rohitjoshixyz commented 2 years ago

Version: 0.7.0 I have acts_as_paranoid set in the CommunityMember model. There is a soft deleted record present in DB with ID 2673197

irb(main):002:0> cm = CommunityMember.with_deleted.find 2673197
=> #<CommunityMember id: 2673197, community_id: 24922, user_id: 234, created_at: "2021-12-28 03:10:45.431833000 +0000", deleted_at: "2022-04-14 04:02:13.000000000 +0000>
irb(main):003:0> cm.valid?
=> true
irb(main):004:0> cm.recover!
Traceback (most recent call last):
        1: from (irb):4
ActiveRecord::RecordInvalid (Validation failed: Community member must exist, Community member can't be blank)
irb(main):005:0> cm.recover
=> true