Want more GoRails?

GoRails is packed full with 688 lessons just like this one.

Sign up to get full access or log in to your account and sit back.

How To Update ActionText Attachments

July 11, 2022

Track your progress

Sign in to track your progress and access subscription-only lessons.

Log In

Your Teacher

Hi, I'm Chris. I'm the creator of GoRails, Hatchbox.io and Jumpstart. I spend my time creating tutorials and tools to help Ruby on Rails developers build apps better and faster.

About This Episode

Rails 7 changed the way ActionText attachments work, so we'll be writing a Rake task to walk through each of the embeds and update them with the correct Signed GlobalID.

Notes

If you're seeing 404s on your ActionText attachments all of a sudden, you might have changed your Rails application defaults from 6.x to 7.0 recently. I noticed this affected the forums on one of my Rails applications, so I got digging and found out that algorithm changed between the Rails versions. This is fine, but there's no built-in way to update the SGIDs for the embedded attachments in ActionText::RichText records.

This episode, we'll walk through how to find all the embeds in your RichText records, parse the HTML, read the old GlobalIDs and then update them with new Signed GlobalIDs.

Resources

Want to stay up-to-date with Ruby on Rails?

Join 82,464+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.