From 0ce9288a21e4b431ae83d6cc180692eccd8ef106 Mon Sep 17 00:00:00 2001 From: Martin Meyerhoff Date: Mon, 22 Jan 2024 17:54:07 +0100 Subject: [PATCH] Import legacy items after routes are generated When importing legacy menu items into the new storefront's API, the `import_menu_items_from_backend` method will try reading the legacy menu item's paths. Those path might be defined in lambdas referencing route helpers, but those route helper are only available after the application's routes have been fully loaded. I understand this is somewhat kludgy, but on the upside: It works. --- .../templates/config/initializers/solidus_admin.rb.tt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/admin/lib/generators/solidus_admin/install/templates/config/initializers/solidus_admin.rb.tt b/admin/lib/generators/solidus_admin/install/templates/config/initializers/solidus_admin.rb.tt index 232d839007b..ca66a8e78bc 100644 --- a/admin/lib/generators/solidus_admin/install/templates/config/initializers/solidus_admin.rb.tt +++ b/admin/lib/generators/solidus_admin/install/templates/config/initializers/solidus_admin.rb.tt @@ -14,9 +14,15 @@ SolidusAdmin::Config.configure do |config| # you can import menu_items from the backend by uncommenting the following line, # but you will need to <%- if defined? Spree::Backend -%> - config.import_menu_items_from_backend! + Rails.application.config.after_initialize do + Rails.application.reload_routes! + config.import_menu_items_from_backend! + end <%- else -%> - # config.import_menu_items_from_backend! + # Rails.application.config.after_initialize do + # Rails.application.reload_routes! + # config.import_menu_items_from_backend! + # end <%- end -%> # Add custom paths to importmap files to be loaded.