Skip to content

#serialized_json for empty collection #466

@jji-fieldwire

Description

@jji-fieldwire

Hi,

Behavior for serializer passed empty collection is to return nil

I think it would make more sense for the serializer to return []. Ideally would work with empty Array and empty Relation.

##### Current behavior
UserSerializer.new([]).serialized_json
=> nil

##### Desired behavior(?)
UserSerializer.new(User.where.not(id: nil)).serialized_json
=> "[]"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions