fastjsonapi serializer error | NameError (uninitialized constant <my serializer class>)

608 views Asked by At

I have just added the gem 'fast_jsonapi' for serialization of my rails api data into json.

I have a model class of Website created. Below is the serializer class I want to access data through:

class WebsiteSerializer
  include FastJsonapi::ObjectSerializer
  attributes :name, :image_url, :slug

  has_many :reviews
end

So, I run the command below in the rails console.

$ web = Website.first
$ WebsiteSerializer.new(web).serialized_json

It gives the error:

Traceback (most recent call last):
        2: from (irb):14
        1: from (irb):15:in `rescue in irb_binding'
NameError (uninitialized constant WebsiteSerializer)
1

There are 1 answers

0
Chandler Buck On

The fast_jsonapi serializer is no longer supported, use jsonapi-serializer instead:

Jsonapi-serializer