Where should I put ActiveStorage purge methods in the controller?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Where should I put ActiveStorage purge methods in the controller?

Nicholas Shirley
I'm trying to figure out where the best place to put ActiveStorage purge methods in the controller. I have tried a few things, but nothing feels really right. Originally, I had them set up as custom endpoints with purge methods, but having them on each resource with files was a little bit tedious. At the moment, I am piggybacking them onto the delete method of each controller with a conditional (one branch handles deleting attachments, the other deleting the object) which looks ugly, but keeps the routes and methods clean.

Something I haven't tried would be to write a stand-alone controller/endpoint to handle all purging under a single destroy method. Seems weird though to write a controller to interface with a method that's built into Rails now. Maybe I am missing something about how AS is supposed to be implemented?

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/91e63cec-d80f-443a-a44c-e966f885bdb5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.