ActiveStorage makes it easy for developers to upload files to cloud services like Amazon S3, Google Cloud Storage,
and more.
It also provides a local disk service for development
and testing.
Rails reads the config value config.active_storage.service
to determine which service to use.
If this value is not set,
Rails will raise an exception.
However, when the config.active_storage.service
is not set,
the application raises a vague error causing unnecessary time lost to debugging.
Before
This value is set in the environment file via the rails active_storage:install
command.
However, in some cases it can be removed or commented out.
Let’s use a simple example to demonstrate this.
We have a User
model with an avatar
attachment.
When we try to upload an avatar, we get the following error:
This is a cryptic error that does not give us any indication of what the problem is.
It takes significant effort to figure out that the config.active_storage.service
is not set.
After
Thanks to this PR
ActiveStorage gives much more descriptive errors when the config.active_storage.service
is not set.