Advanced ActionText: Attaching any Model in rich text
summary
Shows how ActionText attaches @mentions and YouTube embeds by having the browser request a Signed Global ID from Rails, then inserting an ActionText attachment that renders differently in the Trix editor and the final view. Uses Trix, Active Storage, server-side controllers that return attachable SGIDs and HTML partials, and client code with Tribute.js and Stimulus for mentions plus a regex-based URL detector for YouTube. Mentions render as single noneditable attachment objects and updating a user’s name updates every mention on refresh, so the demos work end to end.
AI-written summary · about
chapters (20)
- 0:00Intro
- 0:35What is Action Text?
- 1:48Why not Markdown?
- 5:02How do I use Action Text?
- 7:58ActionText:RichText Stores the rich text content
- 8:24ActionText:Content
- 13:33ActiveStorage::Attachment Stores attachments for Action Text::Rich Texts
- 14:04Customizing Trix
- 18:24Rendering YouTube embed Server generates the HTML from the YouTube video ID
- 20:28Attachable Models YouTube attachable
- 23:54Trix Partials Attachables can have separnte templates for Trix
- 24:14Rendering Attachables Render with to partial path
- 26:07Zurb Tribute
- 26:54Adding Tribute Using a Stimulus Controller
- 29:57User lookup Search users matching the Tributejs query
- 34:02Inserting Tribute selection Trix needs a bit of cleanup before inserting the attachment
- 34:15Attachable Model Mentions response
- 37:04Inserting Trix Attachment
- 37:56User mentions
- 39:03Updating records
related talks
22mBryan's ActieModel Extravaganza
42mPowerful Rails Features You Might Not Know
32mTikTok on Rails
44mRealtime Apps with Hotwire & ActionMailbox
58mBoost Your Razor Pages with HTMX: Simplicity & Power
28mUsing Rails without Rails
43mNow Hear This! Putting Real-Time Voice, Video and Text into Rails
20mWebstrates: Shareable Dynamic Media
