... So you can still build routes with deleted instances. For example:
paranoid = Paranoid.with_deleted.first
edit_paranoid_path( paranoid ))
(Ignore the strange diff on core.rb, the only important lines are 84 - 87. The rest is just my text editor trying to fix certain lines).
Retains the original ActiveRecord behaviour for #persisted? so you ca…
…n still build routes with deleted instances (eg. edit_paranoid_path( paranoid ))
Sorry, I totally forgot about this. Looks good, thanks!
This seems to break respond_with behavior in controllers:
@user = User.find(params[:id])
As the record is now persisted after it has been flagged as deleted, it will redirect to that record which will raise ActiveRecord::RecordNotFound
Is this the intended behaviour?
I realize that you can avoid this by specifying the location or redirecting.
Best guess is that respond_with and it's subsequent methods query your User model in some simple way (like find), thereby using the default scope which is hiding your protected deletions; the proper behavior, I'd say. You should be able to avoid any this type of problem with something like:
Out of curiosity, why are responding back with the deleted resource?
@chuckg I always use respond_with as it automatically sets your response status and keeps your controllers dry. It is also the default in the rails scaffold generators.
Before this change
User.last.destroy.persisted? # false
After this change
User.last.destroy.persisted? # true
Just wondering if a deleted record should be persisted?