2013-11-01 89 views
0

我正在瘋狂2.1上建立一個自定義選項卡,我有我的Deface覆蓋這工作正常,但當我嘗試點擊我的標籤已經在此選項卡上它會去到url/admin/admin/places。所以我需要這個去總是/ admin/places。Spree自定義管理標籤幫助URL損壞覆蓋

找到這個https://codeclimate.com/github/spree/spree/Spree::Admin::NavigationHelper它說該選項卡採取第一個參數,並使路徑admin_places_path。

:insert_after => "[data-hook='admin_tabs']", 
:text   => "<%= tab :places, :icon => 'icon-th-large'%>" 

我嘗試了平時:以「管理員/地方」網址PARAM但得到了同樣的結果,並一直在尋找的標籤實現這導致我codeclimate現在這裏。任何人都知道如何避免這一點?

回答

6

這就是我如何解決:

:text => "<%= tab :places, :icon => 'icon-th-large', url: main_app.admin_places_path %>" 

搜索我的回答,我發現我的地方途徑爲我的應用程序的命名空間內沒有在大禮包。

namespace :admin do 
    # Directs /admin/products/* to Admin::ProductsController 
    # (app/controllers/admin/products_controller.rb) 
    resources :places 
end 

因此,要訪問路徑,我不得不放置「main_app」。目標路徑之前。看到這裏:Adding Routes to Rails' Spree E-Commerce

看codeclimate代碼,我看到url參數被設置爲目的地,並可以使用它來把「main_app」。在路徑之前,現在正在工作。

編輯:

發現這是一個更好的方式來做到這一點。

路線

Spree::Core::Engine.routes.prepend do 
    namespace :admin do 
    # Directs /admin/products/* to Admin::ProductsController 
    # (app/controllers/admin/products_controller.rb) 
    resources :places 
    end 
end 

動了我的所有文件夾(控制器和視圖)從控制器/視圖>地方控制器/視圖>大禮包>管理員>地方

刪除了 「my_app應用。」現在它更好,更容易。