From c522cd61b60ba7d59c3d104dc55522f7862fe9e1 Mon Sep 17 00:00:00 2001 From: Martin Meyerhoff Date: Wed, 4 Oct 2023 15:41:58 +0200 Subject: [PATCH] Namespace routes to our controllers For the transition process between the two promotion systems, we want the admins to still have access to the legacy promotions. Prior to this commit, this access was thwarted as we used the exact same paths as core Solidus. This adds an extra `friendly/` to the path, so that the paths can be distinguished. This in turn revealed we have to use the right routing proxy for the promotions controller, otherwise we'd be sent to actions in the Solidus world. --- .../admin/promotions_controller.rb | 4 ++++ config/routes.rb | 16 +++++++++------- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/app/controllers/solidus_friendly_promotions/admin/promotions_controller.rb b/app/controllers/solidus_friendly_promotions/admin/promotions_controller.rb index ef5bb8bb..65957c9c 100644 --- a/app/controllers/solidus_friendly_promotions/admin/promotions_controller.rb +++ b/app/controllers/solidus_friendly_promotions/admin/promotions_controller.rb @@ -59,6 +59,10 @@ def load_data def location_after_save solidus_friendly_promotions.edit_admin_promotion_url(@promotion) end + + def routes_proxy + solidus_friendly_promotions + end end end end diff --git a/config/routes.rb b/config/routes.rb index 911a8da7..74792e80 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -2,14 +2,16 @@ SolidusFriendlyPromotions::Engine.routes.draw do namespace :admin do - resources :promotion_categories, except: [:show] + scope :friendly do + resources :promotion_categories, except: [:show] - resources :promotions do - resources :promotion_rules - resources :promotion_actions - resources :promotion_codes, only: [:index, :new, :create] - resources :promotion_code_batches, only: [:index, :new, :create] do - get "/download", to: "promotion_code_batches#download", defaults: {format: "csv"} + resources :promotions do + resources :promotion_rules + resources :promotion_actions + resources :promotion_codes, only: [:index, :new, :create] + resources :promotion_code_batches, only: [:index, :new, :create] do + get "/download", to: "promotion_code_batches#download", defaults: {format: "csv"} + end end end end