Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating formatter resource cache fails due to 'Uninitialized constant... ::ThreadSafe' #7

Open
shaunrfield opened this issue Aug 23, 2023 · 0 comments

Comments

@shaunrfield
Copy link

I'm attempting to utilise this library with Rails (7.0.7), Grape (1.7.1), and Ruby (3.2.2). but I'm running into issues when the formatter is attempting to resolve the resource class for the first time. Below is the stack trace. Is there something missing in my setup or is this library no longer supported in these versions of Rails/Ruby?

NameError:
uninitialized constant #<Class:Grape::Formatter::JSONAPIResources>::ThreadSafe

Backtrace:
/usr/local/rvm/gems/default/gems/grape-jsonapi-resources-0.0.7/lib/grape-jsonapi-resources/formatter.rb:85:in `resources_cache'
/usr/local/rvm/gems/default/gems/grape-jsonapi-resources-0.0.7/lib/grape-jsonapi-resources/formatter.rb:89:in `get_resource_for'
/usr/local/rvm/gems/default/gems/grape-jsonapi-resources-0.0.7/lib/grape-jsonapi-resources/formatter.rb:80:in `resource_class_for'
/usr/local/rvm/gems/default/gems/grape-jsonapi-resources-0.0.7/lib/grape-jsonapi-resources/formatter.rb:78:in `resource_class_for'
/usr/local/rvm/gems/default/gems/grape-jsonapi-resources-0.0.7/lib/grape-jsonapi-resources/formatter.rb:19:in `serialize_resource'
/usr/local/rvm/gems/default/gems/grape-jsonapi-resources-0.0.7/lib/grape-jsonapi-resources/formatter.rb:6:in `call'

The basic code setup is as follows:

# app/api/public/v1/topics.rb
module Public
  module V1
    class Topics < ::Grape::API
      include Public::V1::Defaults

      resource :topics do
        desc 'List of available topics which a helpline may support.'
        get do
          render Topics.All
        end
      end
      add_swagger_documentation
    end
  end
end

# app/resources/topic_resource.rb
class TopicResource < JSONAPI::Resource
    attributes :name
end

# config/routes.rb
Rails.application.routes.draw do
  ...
  mount Public::API => '/'
  mount GrapeSwaggerRails::Engine => '/swagger'

  jsonapi_resources :topics
end
@shaunrfield shaunrfield changed the title ThreadSafe Creating formatter resource cache fails due to 'Uninitialized constant... ::ThreadSafe' Aug 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant