无法在rails引擎中调用`spree_current_user`

时间:2017-04-24 06:31:11

标签: ruby-on-rails spree

我正在构建一个可安装的rails(4.0.13)引擎,为我现有的狂欢应用添加一些功能。

我的app/engines/my_engine/app/controllers/my_engine/application_controller.rb

module MyEngine
  class ApplicationController < ActionController::Base
    include Spree::Core::Engine.routes.url_helpers
    include Spree::Core::Engine.helpers
    include Spree::Core::ControllerHelpers
  end
end

在引擎的一个控制器内部 - app/engines/my_engine/app/controllers/my_engine/some_controller.rb我有

require_dependency "my_engine/application_controller"

module MyEngine
  class SomeController < ApplicationController
    before_action :find_user, except: :destroy
    .
    .
    private
    def find_user
      @user = spree_current_user
    end
  end
end

我得到undefined local variable or method 'spree_current_user' !!

我应该如何在我的引擎内使用狂欢助手?任何帮助非常感谢

1 个答案:

答案 0 :(得分:1)

将此添加到application_controller.rb

build