Query a Single Type Document with Ruby

Here we discuss how to retrieve the content for a Single type document.

getSingle helper function

In this example we are querying for the single instance of the custom type “navigation”. We will do so by using the getSingle query helper function available in the Ruby development kit.

document = api.getSingle("navigation")
# document contains the document content

Without the helper

You can perform the same query without using the helper function. Here we again query the single document of the type "navigation".

response = api.query(Prismic::Predicates.at("document.type", "navigation"))
# response.results[0] contains the document content