3333 require 'bundler_ext'
3434 Bundler . ui = Bundler ::UI ::Silent . new if Rails . env . production?
3535 BundlerExt . system_require ( File . expand_path ( '../Gemfile.in' , __dir__ ) , :all )
36-
37- class Foreman ::Consoletie < Rails ::Railtie
38- console { Foreman . setup_console }
39- end
4036else
4137 # If you have a Gemfile, require the gems listed there
4238 # Note that :default, :test, :development and :production groups
4339 # will be included by default (and dependending on the current environment)
4440 if defined? ( Bundler )
4541 Bundler . ui = Bundler ::UI ::Silent . new if Rails . env . production?
4642
47- class Foreman ::Consoletie < Rails ::Railtie
48- console do
49- begin
50- Bundler . require ( :console )
51- rescue LoadError
52- # no action, logs a warning in setup_console only
53- end
54- Foreman . setup_console
55- end
56- end
5743 Bundler . require ( *Rails . groups )
5844 optional_bundler_groups = %w[ assets ec2 fog libvirt openstack vmware redis ]
5945 optional_bundler_groups . each do |group |
@@ -64,6 +50,22 @@ class Foreman::Consoletie < Rails::Railtie
6450 end
6551end
6652
53+ class Foreman ::Consoletie < Rails ::Railtie
54+ console do |app |
55+ begin
56+ Bundler . require ( :console ) if defined? ( Bundler ) && !defined? ( BundlerExt )
57+ rescue LoadError
58+ # no action, logs a warning in setup_console only
59+ end
60+
61+ Foreman . setup_console
62+
63+ app . reloader . to_prepare do
64+ Foreman . setup_console
65+ end
66+ end
67+ end
68+
6769# Content of these files is being used before Zeitwerk does auto/eager loading
6870# We need to call either require with the full path or require_relative with relative path since /lib is not in $LOAD_PATH yet here
6971# $LOAD_PATH is available in config/initializers though
0 commit comments