2012-08-14 69 views
3

我無法將我的控制器綁定到創建的管理員面板選項卡。我究竟做錯了什麼?Spree的管理面板中的自定義選項卡

的routes.rb

match '/admin/pimport', :to => 'spree/admin/pimport#index', :as => :pimport 

覆蓋/ pimport_tab.rb

Deface::Override.new(
    :name => "pimport_tab", 
    :virtual_path => "spree/layouts/admin", 
    :insert_bottom => "[data-hook='admin_tabs'], #admin_tabs[data-hook]", 
    :text => '<%= tab :pimport %>' 
) 

控制器/大禮包/管理/ pimport_controller.rb

module Spree 
    module Admin 
    class PimportController < Spree::Admin::BaseController 
     def index 
     end 
    end 
    end 
end 

和我的意見/大禮包/管理/ pimport/index.html.erb爲空白。


http://localhost:3000/admin/pimport我得到這個錯誤:

NoMethodError in Spree/admin/pimport#index 

它顯示

/Users/artemaminov/.rvm/gems/[email protected]/gems/spree_core-1.1.3/app/views/spree/layouts/admin.html.erb 

其中線#35提出:

undefined method `admin_pimport_path' for # ActionDispatch::Routing::RoutesProxy:0x007f88d5aacca0> 

提取的源(左右線#35 ):

<div id="admin-menu" data-hook> 
    <ul data-hook="admin_tabs"> 
    <%= render :partial => 'spree/admin/shared/tabs' %> 
    <%= tab(:promotions, :url => spree.admin_promotions_path) %><%= tab :pimport %> 
    </ul> 
    <br class="clear"> 
</div> 
+0

你用什麼版本的施普雷? – thekingoftruth 2012-09-08 09:41:23

回答

0

在routes.rb中應該寫:

Spree::Core::Engine.routes.prepend do 
    match '/admin/pimport', :to => 'admin/pimport#index', :as => :pimport 
end 

或使用命名空間:

Spree::Core::Engine.routes.prepend do 
    namespace :admin do 
    match '/pimport', :to => 'pimport#index', :as => :pimport 
    end 
end 
相關問題