1

我正在尝试在我刚刚添加到我的 spree 应用程序中的控制器中使用 spree_application 布局

class ShotsController < Spree::BaseController

  layout 'spree_application'

  def index
    @shots = Shot.all
  end

  def show
    @shot=Shot.find(params[:id])
  end   

end

但是当我试图去shots_path我有一个错误:

NoMethodError in Shots#index

Showing /Users/me/.rvm/gems/ruby-1.9.3-p327/gems/spree_core-    1.3.2/app/views/spree/shared/_nav_bar.html.erb where line #14 raised:

undefined method `current_order' for #< ShotsController:0x007f9c6b746e40>

有人可以帮助我吗?

4

2 回答 2

0

如果您希望您的控制器成为 Spree 核心的一部分,请尝试将其文件移入app/controllers/spree/并重写如下:

module Spree
  class ShotsController < ApplicationController
    layout 'spree_application'

    def index
      @shots = Shot.all
    end

    def show
      @shot=Shot.find(params[:id])
    end   
  end
end
于 2013-04-26T15:58:38.693 回答
0

好的,只需弄清楚如何:

在 application_controller.rb 文件中包含 Spree::Core::ControllerHelpers::Order

于 2013-04-22T15:34:41.417 回答