Files
fizzy/config/initializers/tenanting/active_storage.rb
T
Mike Dalessio 3844dc9ff3 Patch Active Storage controllers to generate slugged URLs
This really only impacts the Disk service in development.

I proposed this upstream in https://github.com/rails/rails/pull/55248,
but it's not clear if the presence of script_name should _always_
prefix generated URLs, so for now it's local to Fizzy.
2025-07-01 15:56:14 -04:00

20 lines
521 B
Ruby

module ActiveStorageControllerExtensions
extend ActiveSupport::Concern
included do
before_action do
# Add script_name so that Disk Service will generate correct URLs for uploads
ActiveStorage::Current.url_options = {
protocol: request.protocol,
host: request.host,
port: request.port,
script_name: request.script_name
}
end
end
end
Rails.application.config.after_initialize do
ActiveStorage::BaseController.include ActiveStorageControllerExtensions
end