Skip to content

Commit

Permalink
Merge pull request #55 from tvdeyen/fix-controller-patches-loading
Browse files Browse the repository at this point in the history
Ensure we load controller patches after they load
  • Loading branch information
tvdeyen authored Dec 13, 2019
2 parents baf0443 + a20a76a commit 4f6d094
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 27 deletions.
24 changes: 12 additions & 12 deletions lib/alchemy/solidus/alchemy_in_solidus.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
##
# If there is the Devise Constant loaded, we can assume that we use it as the authentication method
# then we set the ParentController of device as the Spree::BaseController
# https://github.com/AlchemyCMS/alchemy-solidus/issues/10
if Object.const_defined?("Devise")
Devise.setup do |config|
config.parent_controller = "Spree::BaseController"
# Make sure we have everything loaded before patching classes
Rails.application.config.to_prepare do
# Allows to render Alchemy content within Solidus' controller views
Spree::BaseController.include Alchemy::ControllerActions
Spree::BaseController.include Alchemy::ConfigurationMethods

# Hook into SolidusAuthDevise controllers if present
if defined? Spree::Auth::Engine
Spree::UserPasswordsController.include Alchemy::ControllerActions
Spree::UserConfirmationsController.include Alchemy::ControllerActions
Spree::UserRegistrationsController.include Alchemy::ControllerActions
Spree::UserSessionsController.include Alchemy::ControllerActions
end
end

# Allow Alchemy content within Solidus views
Spree::BaseController.send :include, Alchemy::ControllerActions
Spree::UserSessionsController.send :include, Alchemy::ControllerActions if defined? Spree::UserSessionsController
Spree::BaseController.send :include, Alchemy::ConfigurationMethods
32 changes: 17 additions & 15 deletions lib/alchemy/solidus/use_solidus_layout.rb
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
# Include this to make Alchemy render within the Solidus layout
# Make sure we have everything loaded before patching classes
Rails.application.config.to_prepare do
# Allows to use Solidus helpers within Alchemys controller views
Alchemy::BaseHelper.include Spree::BaseHelper
Alchemy::BaseHelper.include Spree::CheckoutHelper
Alchemy::BaseHelper.include Spree::ProductsHelper
Alchemy::BaseHelper.include Spree::StoreHelper
Alchemy::BaseHelper.include Spree::TaxonsHelper

Alchemy::BaseHelper.send :include, Spree::BaseHelper
Alchemy::BaseHelper.send :include, Spree::CheckoutHelper
Alchemy::BaseHelper.send :include, Spree::ProductsHelper
Alchemy::BaseHelper.send :include, Spree::StoreHelper
Alchemy::BaseHelper.send :include, Spree::TaxonsHelper

Alchemy::BaseController.send :include, Spree::Core::ControllerHelpers::Auth
Alchemy::BaseController.send :include, Spree::Core::ControllerHelpers::Common
Alchemy::BaseController.send :include, Spree::Core::ControllerHelpers::Order
Alchemy::BaseController.send :include, Spree::Core::ControllerHelpers::PaymentParameters
Alchemy::BaseController.send :include, Spree::Core::ControllerHelpers::Pricing
Alchemy::BaseController.send :include, Spree::Core::ControllerHelpers::Search
Alchemy::BaseController.send :include, Spree::Core::ControllerHelpers::Store
Alchemy::BaseController.send :include, Spree::Core::ControllerHelpers::StrongParameters
Alchemy::BaseController.include Spree::Core::ControllerHelpers::Auth
Alchemy::BaseController.include Spree::Core::ControllerHelpers::Common
Alchemy::BaseController.include Spree::Core::ControllerHelpers::Order
Alchemy::BaseController.include Spree::Core::ControllerHelpers::PaymentParameters
Alchemy::BaseController.include Spree::Core::ControllerHelpers::Pricing
Alchemy::BaseController.include Spree::Core::ControllerHelpers::Search
Alchemy::BaseController.include Spree::Core::ControllerHelpers::Store
Alchemy::BaseController.include Spree::Core::ControllerHelpers::StrongParameters
end

0 comments on commit 4f6d094

Please sign in to comment.