首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >在新控制器中使用spree_application布局

在新控制器中使用spree_application布局
EN

Stack Overflow用户
提问于 2013-04-22 09:29:22
回答 2查看 737关注 0票数 1

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

代码语言:javascript
复制
class ShotsController < Spree::BaseController

  layout 'spree_application'

  def index
    @shots = Shot.all
  end

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

end

但是当我尝试访问shots_path时,我得到了一个错误:

代码语言:javascript
复制
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>

有人能帮我吗?

EN

回答 2

Stack Overflow用户

发布于 2013-04-22 23:34:41

好的,只要弄清楚怎么做就行了:

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

票数 0
EN

Stack Overflow用户

发布于 2013-04-26 23:58:39

如果您希望您的控制器成为Spree内核的一部分,请尝试将其文件移动到app/controllers/spree/中,并按如下方式重写它:

代码语言:javascript
复制
module Spree
  class ShotsController < ApplicationController
    layout 'spree_application'

    def index
      @shots = Shot.all
    end

    def show
      @shot=Shot.find(params[:id])
    end   
  end
end
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16138117

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档