Support the Boolean field inside Slices
Closed this issue ยท 4 comments
jamesmosier commented
With the release of the boolean field and slices it would be great to see these supported together.
Currently when a boolean field is inside a slice the method api.getByID
errors out with a generic undefined method `call' for nil:NilClass
error.
mrschober commented
Further, this bug is not just affecting slices but also queries that return multiple documents when they contain boolean fields.
Until this feature is added, booleans are not usable in Ruby.
sarco3t commented
I was able to fix the issue by overriding prismic parsers list and adding boolean parser.
module JsonParser
class << self
def parsers
@parsers ||= {
'Link.document' => method(:document_link_parser),
'Text' => method(:text_parser),
'Link.web' => method(:web_link_parser),
'Link.image' => method(:image_link_parser),
'Link.file' => method(:file_link_parser),
'Date' => method(:date_parser),
'Timestamp' => method(:timestamp_parser),
'Number' => method(:number_parser),
'Embed' => method(:embed_parser),
'GeoPoint' => method(:geo_point_parser),
'Image' => method(:image_parser),
'Color' => method(:color_parser),
'StructuredText' => method(:structured_text_parser),
'Select' => method(:select_parser),
'Multiple' => method(:multiple_parser),
'Group' => method(:group_parser),
'SliceZone' => method(:slices_parser),
'Separator' => method(:separator_parser),
'IntegrationFields' => method(:integration_fields_parser),
'Boolean' => ->(json) { json['value'] }
}
end
end
end
end
gdotdesign commented
I've ended up doing this:
Prismic::JsonParser.parsers['Boolean'] = ->(json) { json['value'] }