0

ActionText/Trix will store rich text, but will not process/store embeds either locally or on S3. When I drag a file into The progress bar on drag/drop does not progress, but the image shows up and the filename and file size are accurate, as seen here:

Form screenshot showing progress bar not progressing

A regular ActiveStorage attachment on the same model works fine, uploads to S3, etc. so I've ruled out ActiveStorage as the culprit.

Debugging wise:

  • There are no errors reported in console (Safari or Chrome)
  • I did find a variety of posts here on SO with somewhat similar issues, and I tried two primary solutions (re-run rails app:upgrade and ensure CORS is good to go on S3 bucket), however, neither has changed the outcome (file still does not upload directly).
  • This behavior persists in Chrome and Safari, and there are no console errors. The blob in the Network tab shows up as a 200 status.

Application wise:

  • JS is loaded by importmaps, and trix and action text are required in the application.js file.
  • The application is Rails 7.0.6 on Ruby 3.2.2, but this is an older Rails app that's been through some upgrades (started on 5.x).
John Athayde
  • 580
  • 2
  • 13
  • 1
    *JS is loaded by importmaps* - allegedly. looks like `actiontext.js` is not loaded, it does the actual uploading. what you're seeing is trix showing a local preview. https://guides.rubyonrails.org/action_text_overview.html#installation – Alex Aug 09 '23 at 22:22
  • Huh, fascinating. So they are called in application.js with requires (in packs folder). Putting them in import statements in applciation.js errors out - seems to be a webpack vs importmaps thing. I was able to included them from a CDN and the image now uploads and is inserted into an activestorage blob. The rich_text_area doesn't save the file, however. – John Athayde Aug 10 '23 at 03:11
  • should probably pick webpack or importmaps, not both. *CORS is good to go* - is it? https://stackoverflow.com/questions/76790608/rails-7-rich-text-not-showing-attached-media-content – Alex Aug 10 '23 at 06:25
  • I thought I had exorcized webpack (there's no package.json, etc) but will verify. CORS is good and the file saves to S3 fine now from Trix. I'll watch the network tab and see if something new pops up (e.g. a read back from s3 failling or something). Trix doesn't store it in the rich_text, but does store other HTML. – John Athayde Aug 10 '23 at 13:54

0 Answers0