Rails 7.1 raises RuntimeError if Active Storage service is not specified

Ghouse Mohamed

Ghouse Mohamed

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:

Failed 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:

Missing 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.

If this blog was helpful, check out our full blog archive.

Stay up to date with our blogs.

Subscribe to receive email notifications for new blog posts.