Active Storage For Multiple Images | Validate & Resize | Ruby on Rails 5.2

Ruby On Rails

Video is ready, Click Here to View ×


This Active Storage tutorial for Ruby on Rails 5.2 covers uploading multiple images, resizing them, and validating them. Because Active Storage doesn’t have image validation built in, we’ll have to create a custom method to do the validating for us.

Because Active Storage also doesn’t resize images for us, we’ll need to use the MiniMagick gem and the ImageMagick program to do the resizing. By combining all of these functions, we get a feature rich image uploading application capable of…

7 thoughts on “Active Storage For Multiple Images | Validate & Resize | Ruby on Rails 5.2

  1. file_field_tag is giving me trouble. I have this in my form:
    file_field_tag(:image_attachments, multiple: true, direct_upload: true, class: 'drop-target')

    But when it comes through into Rails I get this in params:
    {"utf8"=>"✓",
    "image_attachments"=>"eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBIQT09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19–88fdb5b4b5c354db2e6779f0fb568cbc159b924d",
    "commit"=>"Upload",
    "action"=>"create",
    "product_id"=>"5355"}

    It gives me some kind of garbage String instead of an array of files!

  2. New to Ruby and Ruby on Rails and i gotta say, you and your videos are amazing. Was a bit put off from web dev a while back but i see myself getting back into it thanks to your videos. Keep up the good work

  3. I accidentally skipped the active storage install, but already migrated the database. Will I need to migrate the database again after installing active storage?

Leave a Reply

Your email address will not be published. Required fields are marked *