0

How I can fix:

ERROR: JSONAPI::Serializable::UndefinedSerializableClass: No 
serializable class defined for Post
app/controllers/api/v1/posts_controller.rb:20:in `index'

Using this gems:

gem 'jsonapi_suite'
gem 'jsonapi-rails'
Mohamed Ziata
  • 1,186
  • 1
  • 11
  • 21

1 Answers1

2

You need to set a class argument to render_jsonapi.

# app/controllers/api/v1/posts_controller.rb
module Api
  module V1
    class PostsController < Api::V1::ApplicationController
      # ...

      def index
        posts = Post.all
        render_jsonapi(posts, class: { Post: Api::V1::SerializablePost })
      end

      # ...
    end
  end
end
Mohamed Ziata
  • 1,186
  • 1
  • 11
  • 21