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

JSONAPI::Serializable::UndefinedSerializableClass: No serializable class defined for User::Perspective #122

Closed
rgaufman opened this issue Apr 19, 2022 · 1 comment

Comments

@rgaufman
Copy link

rgaufman commented Apr 19, 2022

I renamed the Perspective model to User::Perspective. It is the same serializable model:

tether-x(dev)> User::Perspective.where(user_id: 'a')
=> #<Mongoid::Criteria
  selector: {"user_id"=>"a"}
  options:  {}
  class:    User::Perspective
  embedded: false>

However I get this exception now for:

def index
  render jsonapi: User::Perspective.where(user_id: user_id)
end

This is the exception:

  1) Api::V3p::PerspectivesController GET#index Authorised returns list of perspectives with jsonapi style
     Failure/Error: render jsonapi: User::Perspective.where(user_id: user_id)

     JSONAPI::Serializable::UndefinedSerializableClass:
       No serializable class defined for User::Perspective
     # /opt/homebrew/lib/ruby/gems/3.1.0/gems/jsonapi-serializable-0.3.1/lib/jsonapi/serializable.rb:28:in `resource_for'
     # /opt/homebrew/lib/ruby/gems/3.1.0/gems/jsonapi-serializable-0.3.1/lib/jsonapi/serializable.rb:16:in `block in resources_for'
     # /opt/homebrew/lib/ruby/gems/3.1.0/gems/jsonapi-serializable-0.3.1/lib/jsonapi/serializable.rb:15:in `map'
     # /opt/homebrew/lib/ruby/gems/3.1.0/gems/jsonapi-serializable-0.3.1/lib/jsonapi/serializable.rb:15:in `resources_for'
     # /opt/homebrew/lib/ruby/gems/3.1.0/gems/jsonapi-serializable-0.3.1/lib/jsonapi/serializable/renderer.rb:45:in `render'
     # /opt/homebrew/lib/ruby/gems/3.1.0/gems/jsonapi-rails-0.4.0/lib/jsonapi/rails/renderer.rb:16:in `render'

Any ideas?

@rgaufman
Copy link
Author

Ah, the solution here helped! < jsonapi-rb/jsonapi-rails#68

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