Recall & Review
beginner
What is Active Storage in Rails?
Active Storage is a built-in Rails framework that helps you upload, store, and attach files like images to your models easily.
Click to reveal answer
beginner
How do you attach an image to a model using Active Storage?
You add
has_one_attached :image or has_many_attached :images in your model, then use model.image.attach(io: file, filename: 'name.jpg') to attach the file.Click to reveal answer
intermediate
What is the purpose of variants in Active Storage?
Variants let you create resized or transformed versions of images on the fly, like thumbnails, without changing the original file.Click to reveal answer
intermediate
Which gem does Rails use by default for image processing with Active Storage?
Rails uses the
image_processing gem, which wraps libraries like MiniMagick or libvips to handle image resizing and transformations.Click to reveal answer
advanced
How can you serve uploaded files securely in Rails?
Active Storage uses signed, temporary URLs to serve files securely, preventing unauthorized access and allowing control over file expiration.
Click to reveal answer
Which method attaches a single file to a Rails model using Active Storage?
✗ Incorrect
The method
has_one_attached declares a one-to-one attachment for a model.What does the
variant method do in Active Storage?✗ Incorrect
Variants create resized or transformed versions of images without changing the original.
Which gem is commonly used by Rails for image processing tasks?
✗ Incorrect
Rails uses the
image_processing gem, which can use MiniMagick internally.How does Active Storage ensure secure file access?
✗ Incorrect
Active Storage generates signed URLs that expire to control access.
Which declaration allows attaching multiple files to a model?
✗ Incorrect
has_many_attached lets a model hold many attached files.Explain how to set up image uploading in a Rails model using Active Storage.
Think about model declarations and attaching files.
You got /4 concepts.
Describe how Active Storage handles image resizing and why it is useful.
Consider how to show smaller images without losing originals.
You got /4 concepts.