Skip to content

Commit

Permalink
Merge pull request #43 from nebulab/kennyadsl/fix-code-reloading
Browse files Browse the repository at this point in the history
Push decorators to autoload path using config.autoload_paths
  • Loading branch information
kennyadsl authored Apr 15, 2020
2 parents 0da89c0 + 51c3c42 commit 14800b0
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions lib/solidus_support/engine_extensions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ def self.included(engine)
engine.extend ClassMethods

engine.class_eval do
solidus_decorators_root.glob('*') do |decorators_folder|
config.autoload_paths += [decorators_folder]
end

config.to_prepare(&method(:activate))

enable_solidus_engine_support('backend') if SolidusSupport.backend_available?
Expand All @@ -19,14 +23,6 @@ def self.included(engine)

module ClassMethods
def activate
if Rails.respond_to?(:autoloaders) && Rails.autoloaders.main
# Add decorators folder to the Rails autoloader. This tells Zeitwerk to treat paths
# such as app/decorators/controllers as roots.
solidus_decorators_root.glob('*') do |decorators_folder|
Rails.autoloaders.main.push_dir(decorators_folder)
end
end

load_solidus_decorators_from(solidus_decorators_root)
end

Expand Down

0 comments on commit 14800b0

Please sign in to comment.