Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always set ActiveStorage::Current.host in base controllers #3613

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -10,10 +10,10 @@ class BaseController < ActionController::Base
protect_from_forgery unless: -> { request.format.json? }

include CanCan::ControllerAdditions
include Spree::Core::ControllerHelpers::CurrentHost
include Spree::Core::ControllerHelpers::Store
include Spree::Core::ControllerHelpers::Pricing
include Spree::Core::ControllerHelpers::StrongParameters
include ActiveStorage::SetCurrent if Spree::Config.active_storage_enabled?

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 @@ -4,13 +4,13 @@
require_dependency 'spree/core/controller_helpers/strong_parameters'

class Spree::BaseController < ApplicationController
include Spree::Core::ControllerHelpers::CurrentHost
include Spree::Core::ControllerHelpers::Auth
include Spree::Core::ControllerHelpers::Common
include Spree::Core::ControllerHelpers::PaymentParameters
include Spree::Core::ControllerHelpers::Search
include Spree::Core::ControllerHelpers::Store
include Spree::Core::ControllerHelpers::StrongParameters
include ActiveStorage::SetCurrent if Spree::Config.active_storage_enabled?

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 @@ -589,11 +589,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
1 change: 1 addition & 0 deletions core/lib/spree/core.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ class GatewayError < RuntimeError; end
require 'spree/core/current_store'
require 'spree/core/controller_helpers/auth'
require 'spree/core/controller_helpers/common'
require 'spree/core/controller_helpers/current_host'
require 'spree/core/controller_helpers/order'
require 'spree/core/controller_helpers/payment_parameters'
require 'spree/core/controller_helpers/pricing'
Expand Down
17 changes: 17 additions & 0 deletions core/lib/spree/core/controller_helpers/current_host.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# frozen_string_literal: true

module Spree
module Core
module ControllerHelpers
module CurrentHost
extend ActiveSupport::Concern

included do
before_action do
ActiveStorage::Current.host = request.base_url
end
end
end
end
end
end