lib/bulkrax/engine.rb in bulkrax-5.3.1 vs lib/bulkrax/engine.rb in bulkrax-5.4.0

- old
+ new

@@ -21,17 +21,18 @@ nil end end config.after_initialize do - my_engine_root = Bulkrax::Engine.root.to_s - paths = ActionController::Base.view_paths.collect(&:to_s) - hyrax_path = paths.detect { |path| path.match(/\/hyrax-[\d\.]+.*/) } - paths = if hyrax_path - paths.insert(paths.index(hyrax_path), my_engine_root + '/app/views') - else - paths.insert(0, my_engine_root + '/app/views') - end - ActionController::Base.view_paths = paths + # We want to ensure that Bulkrax is earlier in the lookup for view_paths than Hyrax. That is + # we favor view in Bulkrax over those in Hyrax. + if defined?(Hyrax) + my_engine_root = Bulkrax::Engine.root.to_s + hyrax_engine_root = Hyrax::Engine.root.to_s + paths = ActionController::Base.view_paths.collect(&:to_s) + hyrax_view_path = paths.detect { |path| path.match(%r{^#{hyrax_engine_root}}) } + paths.insert(paths.index(hyrax_view_path), File.join(my_engine_root, 'app', 'views')) if hyrax_view_path + ActionController::Base.view_paths = paths.uniq + end end end end