The devise-api gem is a convenient way to add authentication to your Ruby on Rails application using the devise gem. It provides support for access tokens and refresh tokens, which allow you to authenticate API requests and keep the user's session active for a longer period of time on the client side
MIT License
152
stars
22
forks
source link
undefined local variable or method `resource_class' #24
I'm trying to figure out if I'm missing something or if it is a bug.
I'm doing some tests with a clean install and default configuration and yet in case of an invalid or empty token I get undefined local variable or method 'resource_class', I found a workaround by defining a resource_class method in my Api::ApplicationController which doesn't seems to affect the correct behavior.
Thanks for your support!
xKraty
# frozen_string_literal: true
module Api
class ApplicationController < ActionController::Base
skip_before_action :verify_authenticity_token, raise: false
before_action :authenticate_devise_api_token!
# Workaround to return errors in case of an invalid token
def resource_class
User
end
end
end
# frozen_string_literal: true
module Api
class HealthController < ::Api::ApplicationController
def index
render json: { message: 'Ready to roll! '}
end
end
end
Hello, thanks for your work!
I'm trying to figure out if I'm missing something or if it is a bug. I'm doing some tests with a clean install and default configuration and yet in case of an invalid or empty token I get
undefined local variable or method 'resource_class'
, I found a workaround by defining aresource_class
method in myApi::ApplicationController
which doesn't seems to affect the correct behavior.Thanks for your support! xKraty