Tengo un controlador de usuarios estoy usando Rails 6 API y estoy usando la gema JWTSessions para autenticar usuarios en la documentacion me indica que agrege el siguiente metodo:
class ApplicationController < ActionController::API
include JWTSessions::RailsAuthorization
rescue_from ActionController::ParameterMissing, with: :bad_request
rescue_from ActiveRecord::RecordInvalid, with: :unprocessable_entity
rescue_from ActiveRecord::RecordNotFound, with: :not_found
rescue_from JWTSessions::Errors::Unauthorized, with: :not_authorized
rescue_from JWTSessions::Errors::ClaimsVerification, with: :forbidden
rescue_from ResetPasswordError, with: :not_authorized
private
def current_user
@current_user ||= User.find(payload['user_id'])
end
end
Al mandar llamar el metodo current_user desde users_controller.rb
class UsersController < ApplicationController
before_action :authorize_access_request!
def me
render json: current_user
end
end
La ruta para llamar al metodo me es la siguiente routes.rb
Rails.application.routes.draw do
post 'refresh', controller: :refresh, action: :create
post 'signin', controller: :signin, action: :create
post 'signup', controller: :signup, action: :create
delete 'signin', controller: :signin, action: :destroy
get 'me', controller: :users, action: :me
end
He logeado correctamente al usuario pero al mandar llamar el metodo me obtengo el siguiente error
undefined local variable or method `current_user'
Me podrian ayudar porque me marca el error si estoy añadiendo los metodos correspondientes gracias