I’ve setup ActiveStorage and ActionText by following the official guides. I can attach images and videos in local environment(localhost:3000). All the things are working well, even after I restart the server.
So I deploy my code change to staging. It looks all good when creating the blog. But I found if I redeploy the code(rebuild the docker image and start service by docker-compose up). The attachments for ActionText will just been invalid, which looks like this:
2
Answers
Finally I found the root case is: https://github.com/rails/rails/issues/37405
It's a Rails bug, when we are using
rich_text_area_tag
, here will be the problem.If you use
rich_text_area
instead this problem will not be there any more.I had a similar problem that was caused by me not configuring
docker-compose
correctly. I had:Disk
for the ActiveStorage "service". This is OK because I don’t expect that my app will store tons of stuff using ActiveStorage–just ActionText blobs in a very limited way.Disk
service to be persistent across restarts. Every time I deployed or otherwise restarted thedocker-compose
services, the volume was recreated, erasing every ActionText blob.Once I properly configured a persistent volume for ActiveStorage, the ActionText attachments started working across deploys/restarts.