Reputation: 14332
I am building a mountable rails (4.0.13) engine to add some functionalities to my existing spree app.
my 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
Inside one of the controllers of the engine - app/engines/my_engine/app/controllers/my_engine/some_controller.rb
I have
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
I am getting undefined local variable or method 'spree_current_user'
!!
what should I do to make use of spree helpers inside my engine? Any help much appreciated
Upvotes: 0
Views: 438
Reputation: 1638
Add this to application_controller.rb
include Spree::AuthenticationHelpers
Upvotes: 1