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

Ensure we load controller patches after they load #55

Merged
merged 1 commit into from
Dec 13, 2019
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
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