Skip to content

Allow configuring the engine storage service independently - #92

Open
akodkod wants to merge 1 commit into
blocknotes:mainfrom
akodkod:akodkod/configurable-db-service
Open

akodkod wants to merge 1 commit into
blocknotes:mainfrom
akodkod:akodkod/configurable-db-service

Conversation

@akodkod

@akodkod akodkod commented Oct 12, 2026

Copy link
Copy Markdown

When an application uses DB storage only for selected attachments, the engine still downloads and uploads through ActiveStorage::Blob.service. With Disk or S3 as the application default, DB attachment requests therefore reach the wrong service.

Add an optional engine configuration:

config.active_storage.service = :local
config.active_storage_db.service = :db

The controller resolves the configured string or symbol through the Active Storage service registry for both downloads and direct uploads. The default is nil, preserving the existing application-default behavior. Unknown names raise the registry error. The application default, signed URLs, and database schema are unchanged.

Includes mixed-storage documentation and request coverage for string/symbol names, downloads, direct uploads, fallback, and unknown names.

Validation

  • Ruby 4.0.7 / Rails 8.1.4 / SQLite: 71 examples, 0 failures.
  • The regression spec produces 5 failures out of 6 examples with the original upstream controller, and passes with this change.
  • RuboCop: all changed Ruby files pass. The full run reports one existing Style/RedundantParentheses offense at spec/service/active_storage/service/db_service_spec.rb:195, unchanged from upstream main.
  • Fasterer: passes.

For the full local suite, installed libvips and added ruby-vips ~> 2.3 through an ignored supplemental validation Gemfile; the currently resolved image_processing 2.2.0 does not bring that dependency into the standard bundle. No dependency changes are included in this PR. The existing upstream workflows cover the broader Rails/database matrix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant