【问题标题】:Spree, add controller to admin pageSpree,将控制器添加到管理页面
【发布时间】:2013-02-03 20:27:45
【问题描述】:

我正在尝试将我的自定义控制器添加到 spree 1.3.1 中的管理部分 而我失败了。我想在顶部菜单中查看我的 contoller.index.html 的 url。我已经这样做了:

/controllers/spree/admin/parsers_controller.rb:

module Spree
  module Admin
    #class ParsersController < Spree::Admin::BaseController
    class ParsersController <  Spree::Admin::ResourceController
      def index

      end

    end
  end
end

污损:

Deface::Override.new(:virtual_path => "spree/layouts/admin",
                     :name => "admin_content_admin_tab_parser",
                     :insert_bottom => "[data-hook='admin_tabs']",
                     :text => "<%= tab :parsers,  :url => spree.admin_parsers_path, :icon => 'icon-th-large' %>",
                     :disabled => false)

routes.rb:

Spree::Core::Engine.routes.prepend do
  namespace :admin do
    resources :parsers
    end
end

index.html.erb

<h1>Parser index.html</h1>

我得到了错误:

您的收据出现同样的错误:

NoMethodError in Spree/admin/overview#index
Showing /home/ssa/spree-1.3.1-0/ruby/lib/ruby/gems/1.9.1/gems/spree_core-1.3.1/app/views/spree/layouts/admin.html.erb where line #54 raised:

undefined method `admin_parsers_path' for #<ActionDispatch::Routing::RoutesProxy:0x0000000612a560>
Extracted source (around line #54):

51:           <div class="sixteen columns main-menu-wrapper">
52:             <ul data-hook="admin_tabs" class="inline-menu fullwidth-menu">
53: <%= render :partial => 'spree/admin/shared/tabs' %>
54:             <%= tab(:promotions, :url => spree.admin_promotions_path, :icon => 'icon-bullhorn') %><%= tab(:users, :url => spree.admin_users_path, :icon => 'icon-user') %><%= tab :parsers,  :url => spree.admin_parsers_path, :icon => 'icon-th-large' %>
55: </ul>
56: </div> 
57:         </div> 

我做错了什么?

【问题讨论】:

  • 请解释您是如何失败的。您的“错误”仅显示输出 HTML,而不是实际错误。另外:您有我们可以克隆并尝试重现此错误的 Rails 应用程序吗?
  • 抱歉,太晚了,我错过了一个错误。这里是。不幸的是,rais 无法为我创建控制器路径。我正在使用简单的 spree 1.3.1 并添加了几行代码的几个文件(它们在问题中)。不幸的是,我在一些公共仓库中没有代码。如果你需要,我可以在某个地方添加它。

标签: ruby-on-rails-3 routes spree


【解决方案1】:

好的,所以问题很简单: Why am I getting "undefined method `assert_valid_keys`"?

无法在我的模型中声明:belongs_to :aThingA, :aThingB 需要:

belongs_to :aThingA
belongs_to :aThingB 

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多