Undefined helper_method for ApplicationController, Rails 5

I am trying to integrate oAuth2.0 in my rails-api application using a gatekeeper. But I keep getting this error, the undefined method is `helper_method for ApplicationController" and still could not find a clear solution on how to solve it. Below is the class application_controller.rb that has helper_method. I follow the guide on the link below. Any help would be appreciated.

https://www.sitepoint.com/getting-started-with-doorkeeper-and-oauth-2-0/

class ApplicationController < ActionController::API

private 

    def current_user
        @current_user ||= User.find(session[:user_id]) if session[:user_id]
    end

    helper_method :current_user

end
+4
source share
2 answers

; . Helpers, "rails-api",

class ApplicationController < ActionController::API
  include ActionController::Helpers
end
+8

API- , helper_method . current_user , ActionController:: Base.

ActionController Github. , AbstractController:: Helpers .

Rails 4, , ActionController:: Helpers. APIDock.

:

#application_controller.rb
class ApplicationController < ActionController::Base
+1

Source: https://habr.com/ru/post/1652637/


All Articles