Skip to content

Commit 72f10ff

Browse files
authored
Add optional actioncable error handling (#17)
1 parent 9e786e3 commit 72f10ff

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

lib/superglue/engine.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,16 @@ class Engine < ::Rails::Engine
2626
#{root}/app/jobs
2727
]
2828

29+
# If the parent application does not use Action Cable, app/channels cannot
30+
# be eager loaded, because it references the ActionCable constant.
31+
# This approach was ported from the amazing folks at turbo-rails
32+
# You can find its MIT License here: https://github.com/hotwired/turbo-rails/blob/main/MIT-LICENSE
33+
initializer :"superglue.no_action_cable", before: :set_eager_load_paths do
34+
unless defined?(ActionCable)
35+
Rails.autoloaders.once.do_not_eager_load("#{root}/app/channels")
36+
end
37+
end
38+
2939
initializer :superglue do |app|
3040
ActiveSupport.on_load(:action_controller) do
3141
next if self != ActionController::Base

0 commit comments

Comments
 (0)