From 2a93666cf02034bd0f8b6415c79972ba8962858f Mon Sep 17 00:00:00 2001 From: Thomas von Deyen Date: Mon, 5 Sep 2022 11:15:26 +0200 Subject: [PATCH] Only default to activestorage adapter if Rails version is supported We only support the activestorage adapter with Rails 6.1 and above, but we default to it, even if the Rails version is 6.0 and below. Since we still support Rails 5.2 and 6.0, we cannot default to the active storage adapter. The app won't boot unless we also change the adapter in the spree initializer. If the initializer, though, is nested in a `config.to_prepare` hook (as recommended from Rails new autoloader zeitwerk [1]) the app refuses to start anyhow, because the config is then taken from the `app_configuration` defaults. [1](https://guides.rubyonrails.org/autoloading_and_reloading_constants.html#use-case-1-during-boot-load-reloadable-code) --- core/lib/spree/app_configuration.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/lib/spree/app_configuration.rb b/core/lib/spree/app_configuration.rb index 79d2d8dce65..3bf7d208fb8 100644 --- a/core/lib/spree/app_configuration.rb +++ b/core/lib/spree/app_configuration.rb @@ -497,7 +497,7 @@ def payment_canceller # @!attribute [rw] image_attachment_module # @return [Module] a module that can be included into Spree::Image to allow attachments # Enumerable of images adhering to the present_image_class interface - class_name_attribute :image_attachment_module, default: 'Spree::Image::ActiveStorageAttachment' + class_name_attribute :image_attachment_module, default: Rails.gem_version >= Gem::Version.new("6.1.0") ? "Spree::Image::ActiveStorageAttachment" : "Spree::Image::PaperclipAttachment" # @!attribute [rw] allowed_image_mime_types # @@ -555,7 +555,7 @@ def payment_canceller # @!attribute [rw] taxon_attachment_module # @return [Module] a module that can be included into Spree::Taxon to allow attachments # Enumerable of taxons adhering to the present_taxon_class interface - class_name_attribute :taxon_attachment_module, default: 'Spree::Taxon::ActiveStorageAttachment' + class_name_attribute :taxon_attachment_module, default: Rails.gem_version >= Gem::Version.new("6.1.0") ? "Spree::Taxon::ActiveStorageAttachment" : "Spree::Taxon::PaperclipAttachment" # Configures the absolute path that contains the Solidus engine # migrations. This will be checked at app boot to confirm that all Solidus