Image for post
Image for post

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:

Cheers!


Image for post
Image for post

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:

Cheers!


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:

Image for post
Image for post

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

About

goncalvesjoao

Been developing for the web since 2007, went to London in 2016, moved to Tokyo in 2017 and now I’m back to Portugal.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store