RubyFlow The Ruby and Rails community linklog


The Ruby and Rails community linklog

Made a library? Written a blog post? Found a useful tutorial? Share it with the Ruby community here or just enjoy what everyone else has found!

Be careful when migrating Rails ActiveStorage app to different server

I’ve been migrating my personal Rails 7 project from Heroku to dedicated server. In this project I heavily rely on ActiveStorage for file uploads/images.

So this task should be really easy: Just pg_dump (or download Heroku PostgreSQL backup) of the existing database, restore it in new server and given you use the same buckets all should work right ?

Well no there are two bottlenecks to be careful about:

1. you need same secret_key_base Any asset uploads are hashed with secret_key_base. So before you delete your Heroku app be sure you save the value of SECRET_KEY_BASE environment variable (and yes it’s different than the one stored in your Rails credentials file)

2 ActionText file uploads are saved with current subdomain If you upload a File using ActionText it will store the full url in the content. That means if you had your application on and you change domain to your action text attachments will not show up. You need to manually change subdomain in DB table records for ActionText

Post a comment

You can use basic HTML markup (e.g. <a>) or Markdown.

As you are not logged in, you will be
directed via GitHub to signup or sign in