Rails 7.1 raises RuntimeError if Active Storage service is not specified

Ghouse Mohamed

By Ghouse Mohamed

on August 23, 2022

This blog is part of our  Rails 7 series.

If Active Storage has been configured, and the service type has not been explicitly set in the respective environment's configuration file, then trying to use active storage throws the following error message:

1Failed to replace attachments_attachments because one or more of the new records could not be saved.

This is not helpful, and it doesn't indicate where to make the required changes for Active Storage to be able to save the attachment(s). It also allows the application to start as if a valid service has been set for Active Storage to use. Starting Rails 7.1, if config.active_storage.service has not been explicitly set, then even attempting to start the application would throw a RuntimeError with the following error message:

1Missing Active Storage service name. Specify Active Storage service name for config.active_storage.service in config/environments/production.rb

Please check out this pull request for more details.

Stay up to date with our blogs. Sign up for our newsletter.

We write about Ruby on Rails, ReactJS, React Native, remote work,open source, engineering & design.