From 17d759340be6f19980d7721d1b8dd3635a846c44 Mon Sep 17 00:00:00 2001 From: John Hawthorn Date: Tue, 21 Nov 2017 13:40:38 -0800 Subject: [PATCH] Insert menu item after "stock" if possible --- lib/solidus_stock_transfers/engine.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/solidus_stock_transfers/engine.rb b/lib/solidus_stock_transfers/engine.rb index aa4aab2..9e1a52a 100644 --- a/lib/solidus_stock_transfers/engine.rb +++ b/lib/solidus_stock_transfers/engine.rb @@ -12,7 +12,9 @@ class Engine < Rails::Engine initializer "add_stock_transfer_menu_item" do Spree::Backend::Config.configure do |config| - config.menu_items << config.class::MenuItem.new( + # Insert after "stock", if that exists + idx = (config.menu_items.index { |item| item.label == :stock } || -2) + 1 + config.menu_items.insert idx, config.class::MenuItem.new( [:stock_transfers], 'exchange', url: :admin_stock_transfers_path