ruby-on-railsrubyspreeapartment-gem

ActiveStorage with Apartment gem only checks public schema to load files instead of tenant schema


I am trying to setup multi-tenancy in my Spree commerce app (ruby 3.2.0, rails 7) using Apartment (ros-apartment fork to be specific).

When I upload files, they get added to the correct tenant schema and I can see it in ActiveStorage::Blob . But when I try to access the images, it only looks at ActiveStorage::Blob in public schema instead of tenant schema and ends up throwing 404 error ->

ActiveRecord::RecordNotFound in ActiveStorage::Representations::ProxyController#show Couldn't find ActiveStorage::Blob with 'id'=1

Do I need to setup something else for it to work correctly ?

I have added the config.middleware.use Apartment::Elevators::Subdomain to my application.rb .

Any help is appreciated, thanks.


Solution

  • It was compatibility issues with Rails 7. I switched to Rails 6.1.2 and it works correctly.

    Looks like the apartment and ros-apartment gems are no longer being maintained.

    Refer: https://github.com/rails-on-services/apartment/issues/234#issuecomment-1756833846