Skip to content
nesquena edited this page Feb 9, 2012 · 7 revisions

RABL allows for varying levels of flexibility depending on the needs of an API. The most extreme of this flexibility is constructing responses not based on a record at all:

object false # uses no record

node(:message) { "..." }
node(:data) do
  @objects.map { |o| { :name => o.name } }
end
node(:meta) { "..." }

Returns:

{
  message: "...",
  data: [{"name" : "foo" }],
  meta: "..."
}

Also take a look at Using Layouts in RABL.