Rails app with mounted volume but not persisted

Hi, I have created a volume and change my config to make assets persistant after a redeploy.

So I’ve added those lines to my fly.toml

[mounts]
  source="dressapp_storage"
  destination="/storage"

And this is my config/storage.yml

test:
  service: Disk
  root: <%= Rails.root.join("tmp/storage") %>

local:
  service: Disk
  root: <%= Rails.root.join("storage") %>

production:
  service: Disk
  root: <%= Rails.root.join("/storage") %>

But when I redeploy my app, images disapeer.

Do you have any clue?

You likely have the following in your config/environments/production.rb:

  # Store uploaded files on the local file system (see config/storage.yml for options).
  config.active_storage.service = :local

Change that to :production, or change your config/storage.yml to point local to /storage.

2 Likes

I’ve replaced “storage” by “data” just like in the documentation and it’s working now.

/storage in fly.toml is relative to the root path.

Rails.root.join("/storage") in config/storage.yml is relative to app root.

It should be a path mismatch.

join does the right thing here:

% rails console
Loading development environment (Rails 7.0.4)
irb(main):001:0> Rails.root.join("/storage").to_s
=> "/storage"
irb(main):002:0>
1 Like