kreeti / kt-paperclip

Easy file attachment management for ActiveRecord
Other
276 stars 94 forks source link

Display attachment attrs when destroying the record #91

Open unijewski opened 2 years ago

unijewski commented 2 years ago

Hey guys! I don't know if you still accept new features or just maintain the gem but there's behaviour that could be slightly modified.

The default behaviour in AR is to return the entire object that was destroyed, see the screenshot below.

Screenshot 2022-05-17 at 17 35 57

When a model includes Paperclip, unfortunately, its attributes are gone when the destroyed object is returned. It's a bit confusing, especially when tracking object changes.

Screenshot 2022-05-17 at 17 56 24

This PR introduces a way to keep the attributes being returned after destroying the record. By default, it doesn't change the original behaviour, but after setting hide_attrs_to_be_destroyed to false within the model, we can see what file data the record had. It works only for the destroy callback, so no changes when we update the file/assign nil.

ssinghi commented 11 months ago

@unijewski can you please sign your commits, so that the PR can be merged. Thanks!

unijewski commented 10 months ago

Hey @ssinghi the commits are signed off now