Closed pjholmes closed 3 years ago
This looks to be related to https://github.com/rails/rails/pull/38957
This workaround looks like your best bet at the moment: https://github.com/rails/rails/pull/38957#issuecomment-780006496
Thank You!
Oh, just noticed the other error in this report. Made https://github.com/rails/rails/pull/41654 for the 500 error; that should be more informative.
Steps to reproduce
Please note I checked the forum and posted these to Stack Overflow with no responses. I always start with the assumption that it's my mistake.
This project is available on Github
1.
Edit
/config/storage.yml
Edit
/app/models/post.rb
Edit
/config/environments/development
to comment out default storage serviceAdd the following to
/app/views/posts/_form.html.erb
Add the following to
app/views/posts/show.html.erb
Create a new post in the UI (with attachments) and display them. Works fine.
Change
/app/views/posts/_form.html.erb
to add direct upload:Try to add a Post. Results in 500.
Changed
config/development.rb
to set a default storage service ofpublic
Restarted Rails and ran the test again. This time there was no 500, but both images were stored in the
public
store (in theactive_storage_blobs
table and on the file system). In other words, theservice: :private
appears to have been ignored in my model:Tried changing the default to :private
Restarted Rails and ran the test again. This time both attachments used the
private
service (again, both in theactive_storage_blobs
table as well as the file system). Again, the service name in the model appears to have been ignored.Commented out the default again to demonstrate the 500 error
Expected behavior
Uploading a file with direct upload without a default storage service configured should not return a 500. Uploading a file with a storage service configured should store the file in the configured storage service.
Actual behavior
When no default storage service is configured, a 500. When a default storage service is configured, the storage service configured in the model appears to be ignored.
System configuration
Rails version: 6.1.3
Ruby version: ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-darwin20]