Search code examples
rails-activestorage

Can ActiveStorage::PurgeJob be enqueued to other than `default`?


There wasn't any queue named default in our Rails code. But it seems Sidekiq sets queue for ActiveStorage::PurgeJob as default. That was why purge_later never worked.

[ActiveJob] Enqueued ActiveStorage::PurgeJob (Job ID: .. ) to Sidekiq(default) with arguments

Is there a way to have different queue name than "default" here? I couldn't find documentation about it yet.


Solution

  • Setting the name of the Active Job queue used by Active Storage

    You can change the queue used by Active Storage for its async jobs at the configuration level like this

    config.active_storage.queue = :low_priority
    

    To make this an application-wide change, put it into your application.rb. For environment-specific changes, put it into the relevant environment file under config/environments

    See the documentation here:
    https://guides.rubyonrails.org/configuring.html#configuring-active-storage