Rails File attachments

We recommend using CarrierWave until ActiveStorage implements proper validations.

Background

It's always been easy to implement the backend solution around uploading a file then referencing said file in a model.

The previous go-to solution was Paperclip. Unfortunately this was discontinued in favor of Rails' own built-in ActiveStorage.

The problem with ActiveStorage

ActiveStorage looks like a good evolution of Paperclip. It even makes it easier to configure the different storage options in 1 file. The biggest downside? It has no built-in validations.

An open Rails issue #33741 tackles this by introducing a new gem on top, activestoragevalidations.

Solution

We recommended using CarrierWave until this is sorted out by the Rails core team. You can also contribute in the issue link above.