Ask A Question

Notifications

You’re not receiving notifications from this thread.

Active Storage (Rails 5.2) vs Shrine

Nicolás Bobb asked in Rails

In the aplication, users have to upload files, I plan to use Amazon S3.
Do you recommend using Rails 5.2 Active Storage, or using the Gem Shrine as explained in Gorails?

What do you recommend?

Reply

Any Gem you have used before? go with that ootion. If you used Shrine before, definitly go with that.
I haven't used AS yet, but have heard it is not as fully featured as, eg Shrine

Reply

Active Storage works fine for file uploads especially to s3 and works nicely, but honestly I'd probably wait a bit until they cut the 5.2 release since there are still some open issues on it. As Jack mentioned it's not as feature-rich as Shrine or other gems. I'm on 5.1.4 and I use either Shrine or Carrierwave as my needs are simple. Honestly, probably best for you to test out both and see which one fits your use case.

Reply

If you need to validate your files, for example validate that only certain file types be uploaded or that some file size constraints (no files bigger than X megabytes) are adhered to, use Shrine.

Also Active Storage currently has no way to retain uploads between form redisplays. So for example if a User uploads a 20MB video to your site and the form needs to get redisplayed because the User has forgotten to input a Video title or some other validation fails, the Video is gone.

There are many other features Active Storage currently lacks, like data URI uploads.

The missing validations and no way to retain uploads on form redisplays make Active Storage more of a toy in comparision with Shrine at the moment. If you can live without those features though, go for Active Storage, as its much simpler to set up.

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 81,842+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    Screencast tutorials to help you learn Ruby on Rails, Javascript, Hotwire, Turbo, Stimulus.js, PostgreSQL, MySQL, Ubuntu, and more.

    © 2024 GoRails, LLC. All rights reserved.