Skip to content

Commit

Permalink
Import legacy items after routes are generated
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mamhoff committed Jan 22, 2024
1 parent 69090d5 commit 0ce9288
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 0ce9288

Please sign in to comment.