Following the CarrierWave tutorial on How to: Add, remove and reorder images using multiple file upload we get to keep our new images while the form is invalid but we still don’t get the ability to remove one file from the recently selected HTML input file ‘multiple’, like the gif above shows.
I wrote this article Break input file files into individual files and preview them to allow this kind of individual file management from one single HTML input file element but we still need to ‘remember’ our new files in case the form is invalid.
So here is a combination of the two articles:
Say you want to make use of input file control ‘multiple’ but you also want to individually choose which files you want to remove and add new ones without loosing all of the previously selected ones.
And while we’re at it, would be nice to preview them too.
Trouble is: input.files is not an easy list to manipulate.
Here’s one way to do it:
Now, let’s go an extra step and preview the files:
Ok. Last detail. Validations and presenting its errors:
So you wanted to help your DevOp friends and decided to created a sweet endpoint that returns the health status of your Rails App, like so:
But alas, your Rails App decides to throw a fit and returns 500 before that endpoint could return something.
How can you still make that endpoint behave correctly while Rails doesn’t?
How can you have an independent App from Rails but still have access to Rails objects?
Enter the Rack! (more info: https://thoughtbot.com/upcase/videos/rack)
So all we have to do is create a Rack App, map it to your path of choice (in this example /health) in the config.ru …