fast_jsonapi icon indicating copy to clipboard operation
fast_jsonapi copied to clipboard

ObjectSerializer not working for single object

Open SahSantoshh opened this issue 5 years ago • 2 comments

fast_jsonapi 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

SahSantoshh avatar Aug 15 '20 11:08 SahSantoshh

FYI #462

davidwparker avatar Sep 11 '20 19:09 davidwparker

@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

abhikanojia avatar Oct 27 '20 11:10 abhikanojia