© Greg Donald 2024
G. DonaldHands-on Test-Driven Developmenthttps://doi.org/10.1007/978-1-4842-9748-3_11

11. Images

Greg Donald1  
(1)
Clarksville, TN, USA
 

In this chapter, we will add the ability to store image files for display in our blog posts. We will leverage the Active Storage gem to provide much of the functionality while working within our own image controller to serve up the image data and to handle missing images.

Active Storage for Images

Rails version 5.2 introduced a new feature called Active Storage that provides file storage functionality. Active Storage allows us to upload files to our Rails application, storing the file binary data as well as metadata, making it the current best way to add images to our blog. I say “current best ...

Get Hands-on Test-Driven Development: Using Ruby, Ruby on Rails, and RSpec now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.