Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
ActiveStorage: Fail more gracefully if file is not found using DiskService #33647
I propose that
It is very common for developers using ActiveStorage to use a cloud service in production and DiskService in development. Also, I doubt I’m the only one who copies my production database on to my development machine as a general practice. That means that when ActiveStorage::Blobs are resolved, valid references to S3 become invalid references to
If people think this is a good idea, I’d like to tackle it. This is what I’m thinking, although it could be quite off base.
I could simply add
rescue_from Errno::ENOENT do head :not_found end
Alternatively, if that’s too specific for the level of abstraction those controllers are at, I could modify
I welcome your thoughts and hope you find this a reasonable proposal. I would love to stop having to run
I’m less sure about
Okay, I’ll make sure the not found errors from all the services are taken care of. That seems like a good thing to do even if it seems less likely to occur with a cloud provider.
I understand your reasoning for
I just remembered that
Can you share the stack trace you see for
Here is an example of the stack traces I’m talking about. This is, in a sample app, the log output of one page load that has this on the page.
<img src="<%= url_for @user.image %>" /> <img src="<%= url_for @user.image.variant resize: "100x100" %>" />
To simulate having copied down the prod db, and the corresponding references that break when the active storage service is changed from s3 to disk, I deleted the contents of