Ruby on Rails Images Disappear after Deploy
jstrocel
HOBBYOP

a month ago

Hello,

I've noticed that whenever I redeploy my app, all of the images I've stored on activestorage disappear, leaving a 404 message. I've heard you need to add something like set :shared_dirs, fetch(:shared_dirs, []).push('storage') to your config/deploy.rb file, but I'm not sure that works for Rails 8. How do I make this work for my application?

Thanks,

-James

$10 Bounty

4 Replies

Railway
BOT

a month ago

Railway's filesystem is ephemeral, so any files written to disk (including ActiveStorage uploads) are lost on each deploy. To persist files, you need to attach a Volume to your service and configure ActiveStorage to use the volume's mount path (e.g., mount the volume at /app/storage so it aligns with where Rails writes ActiveStorage files by default).


Status changed to Awaiting User Response Railway about 1 month ago


jstrocel
HOBBYOP

a month ago

I attached the volume to the service running my rails app, I mounted the volume at /app/storage , and the images still disappeared on a redeploy. I changed the volume mount to /storage , and I got the same result. I seem to be missing some steps here, what are they?


Status changed to Awaiting Railway Response Railway about 1 month ago


Status changed to Open Railway about 1 month ago


jstrocel
HOBBYOP

a month ago

I changed the volume mount to /rails/storage and added the environment variable RAILWAY_RUN_UID=0 to the rails app service. Do I get a $10 bounty now?


Status changed to Open sam-a about 1 month ago


sam-a
EMPLOYEE

a month ago

I'm glad you resolved your problem - unfortunately we do not pay bounties to the original poster. You do get the joy of success (as well as the benefits of having a solved problem).

Have a great night!


Welcome!

Sign in to your Railway account to join the conversation.

Loading...