Action Text Images Not uploading
I have action text working fine except that when images are added they aren't actually uploaded.
It appears to work in the editor, but since the upload fails it doesn't get saved to the rich_text field.
In the console I see this when dragging an image in:
It appears to work in the editor, but since the upload fails it doesn't get saved to the rich_text field.
In the console I see this when dragging an image in:
[Error] Failed to load resource: the server responded with a status of 404 (Not Found) (undefined, line 0) [Error] Error: Direct upload failed: Error creating Blob for "marble-numbers-1.png". Status: 404 directUploadDidComplete (administrate-86ab6c242671f51e9aa2.js:7101) directUploadDidComplete (anonymous function) (administrate-86ab6c242671f51e9aa2.js:8038) requestDidError (administrate-86ab6c242671f51e9aa2.js:7923) requestDidLoad (administrate-86ab6c242671f51e9aa2.js:7917)
The network reveals the request that was made:
POST /admin/videos/4/undefined Initiator: activestorage.js:739
On that line of activestorage I see this:
createClass(BlobRecord, [{ key: "create", value: function create(callback) { this.callback = callback; this.xhr.send(JSON.stringify({ <-- this line blob: this.attributes })); }
I'm not sure what I'm missing here. Any ideas?
Wow this took an embarrassingly long time to figure out 🤦🏻♂️
The builtin administrate field for TrixField looks like this:
The builtin administrate field for TrixField looks like this:
<div class="field-unit__field"> <%= f.hidden_field field.attribute, id: field.attribute %> <trix-editor input="<%= field.attribute %>"> </div>
This doesn't give the editor any data attributes to tell actiontext where to upload images.
Instead it should leverage the Rails form helper:
<div class="field-unit__field"> <%= f.rich_text_area field.attribute %> </div>
Added a PR to Rails to hopefully make this type of thing easier for others to track down: https://github.com/rails/rails/pull/40505
Notifications
You’re not receiving notifications from this thread.