Skip to content

Commit

Permalink
Simplify checks to include ActiveStorage modules in controllers
Browse files Browse the repository at this point in the history
ActiveStorage disk service needs current host to be correctly set by
ActiveStorage:SetCurrent concern. The concern should be included in base
controllers only if is defined, there's non need to check if we are
currently using ActiveStorage based attachment adapters. This way we
avoid loading uneccessary modules during initialization process that
could potentially conflict with custom attachment adapters.
  • Loading branch information
filippoliverani committed May 12, 2020
1 parent 8b72292 commit 270cd53
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 8 deletions.
2 changes: 1 addition & 1 deletion api/app/controllers/spree/api/base_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class BaseController < ActionController::Base
include Spree::Core::ControllerHelpers::Store
include Spree::Core::ControllerHelpers::Pricing
include Spree::Core::ControllerHelpers::StrongParameters
include ActiveStorage::SetCurrent if Spree::Config.active_storage_enabled?
include ActiveStorage::SetCurrent if defined? ActiveStorage::SetCurrent

class_attribute :admin_line_item_attributes
self.admin_line_item_attributes = [:price, :variant_id, :sku]
Expand Down
2 changes: 1 addition & 1 deletion core/app/controllers/spree/base_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Spree::BaseController < ApplicationController
include Spree::Core::ControllerHelpers::Search
include Spree::Core::ControllerHelpers::Store
include Spree::Core::ControllerHelpers::StrongParameters
include ActiveStorage::SetCurrent if Spree::Config.active_storage_enabled?
include ActiveStorage::SetCurrent if defined? ActiveStorage::SetCurrent

respond_to :html
end
6 changes: 0 additions & 6 deletions core/lib/spree/app_configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -585,11 +585,5 @@ def admin_vat_location
country: Spree::Country.find_by(iso: admin_vat_country_iso)
)
end

def active_storage_enabled?
@active_storage_enabled ||=
Spree::Config.image_attachment_module == Spree::Image::ActiveStorageAttachment ||
Spree::Config.taxon_attachment_module == Spree::Taxon::ActiveStorageAttachment
end
end
end

0 comments on commit 270cd53

Please sign in to comment.