Netflix / fast_jsonapi

No Longer Maintained - A lightning fast JSON:API serializer for Ruby Objects.
Apache License 2.0
5.07k stars 425 forks source link

ObjectSerializer not working for single object #472

Open SahSantoshh opened 3 years ago

SahSantoshh commented 3 years ago

_fastjsonapi version: 1.5 The object serializer is working fine if an array of objects is passed to serializer:

def index
    contents = Content.page params[:page]
    render json: ContentSerializer.new(contents)
end

But it doesn't work for single object

def show
   options = {}
   options[:include] = %i[content_texts image_labels]
   render json: ContentSerializer.new(@content).serializable_hash, status: 200
end
davidwparker commented 3 years ago

FYI #462

abhikanojia commented 3 years ago

@SahSantoshh Since you haven't posted any issue backtrace or error.

I am guessing the Content model has :size attribute or method defined on it which causes the issue.

Try to use the new repo which doesn't have this issue https://github.com/jsonapi-serializer/jsonapi-serializer