2017-04-24 53 views
0

我正在构建一个可挂载的rails(4.0.13)引擎,以将一些功能添加到现有的spree应用程序中。无法在rails引擎内调用`spree_current_user`

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'

我应该怎么做才能在我的引擎中使用spree助手?任何帮助非常赞赏

+1

尝试添加这对您的应用程序控制器'包括施普雷:: AuthenticationHelpers' – Sajin

+0

@Sajin加入'包括施普雷:: AuthenticationHelpers'固定的问题..非常感谢 –

+0

我应该添加它作为答案? – Sajin

回答

1

添加这application_controller.rb

include Spree::AuthenticationHelpers