Description
I was just debugging an issue when trying to revive a deleted record, and I found that that when reviving the dependent associations for the record, the query is not scoped to the parent record. By that I mean the query does not include the foreign key. Rather it merely looks for any record of the given type that happened to be deleted within the timeframe of the deleted_at (plus/minus the depended_record_window).
The result is that completely unrelated records could be revived if they happened to be deleted around the same time (something quite likely on a high traffic app). Surely this isn't the way it is meant to work is it?
My expectation is that query generated by add_record_window
method would include the foreign_key of the containing record. See: https://github.com/JackDanger/permanent_records/blob/master/lib/permanent_records.rb#L134-L144
I can try to create a patch for this issue, but first I would like to know if this is working 'as designed' if there is not reason the foreign key is not included?