fast_jsonapi icon indicating copy to clipboard operation
fast_jsonapi copied to clipboard

Params & Sparse Fieldsets

Open LuisHCK opened this issue 6 years ago • 2 comments

I am trying to achieve something similar to what is described in the JSON API documentation: JSON API - Sparse Fieldsets

im doing the request:rooms?include=[user]

in my controller:

RoomSerializer.new(rooms, params).serialized_json

but the response is

    "exception": "#<NoMethodError: undefined method `delete_if' for \"[user]\":String\nDid you mean?  delete\n               delete!>"

I understand that the error refers to the fact that params is passing a String, even though I am sending the header Content-Type:application/json Any ideas or suggestions to solve this?

LuisHCK avatar Oct 21 '18 05:10 LuisHCK

If you send the params directly to the serializer without any changes then your request should look more like : rooms?include[]=user

stefatkins avatar Oct 21 '18 07:10 stefatkins

@LuisHCK as per the given error, it looks more an error on your application code. We can solve this only if you provide more details - the entire code of your serializer and controller action and the stack traces - but first, please make sure to submit a failing test if you think this is a problem with this gem.

manojmj92 avatar Oct 21 '18 13:10 manojmj92