-
Notifications
You must be signed in to change notification settings - Fork 21.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ActiveStorage: DirectUploads - 'undefined' instead item.signed_id in params #32365
Comments
/cc @javan |
Do you have |
Yes |
Thanks, that's the issue. It should work if you set it to rails/railties/lib/rails/generators/rails/app/templates/config/initializers/wrap_parameters.rb.tt Lines 12 to 15 in bc9fb9c
We'll need to update the controller to ensure the response isn't wrapped. Any objections to this change, @georgeclaghorn? --- a/activestorage/app/controllers/active_storage/direct_uploads_controller.rb
+++ b/activestorage/app/controllers/active_storage/direct_uploads_controller.rb
@@ -15,7 +15,7 @@ def blob_args
end
def direct_upload_json(blob)
- blob.as_json(methods: :signed_id).merge(direct_upload: {
+ blob.as_json(root: false, methods: :signed_id).merge(direct_upload: {
url: blob.service_url_for_direct_upload,
headers: blob.service_headers_for_direct_upload
}) |
No objection. |
The JavaScript component expects a bare response. Fixes rails#32365
Leaving a comment here just in case. I ran into this error
for a model with an attachment on the Looking at the |
Upon further investigation, I believe the error I encountered matches the scenario in issue #31985 . The error message is what originally led me to this issue. Hopefully this will help someone else who stumbles across this page. |
Steps to reproduce
I want to add the incredible ActiveStorage feature to my project, but I've faced a problem with direct uploads.
I've used rails guides for setup.
Expected behavior
After the direct upload is done activestorage.js should put signed_id to the hidden input value and submit a form.
Actual behavior
File saved, everything is fine, but the value of the hidden input:
<input type="hidden" name="meeting[documents][]" value="undefined">
and form get submitted.
I've found what
i.signed_id
returnsundefined
here:And changed this to
i.blob.signed_id
, what (I'm not sure) fixes the problem.Anyone else faced this problem? Or I broke something?
System configuration
Rails version: 5-2-stable
Ruby version: ruby 2.4.1
The text was updated successfully, but these errors were encountered: