3

I have a v1/queues/index.rabl like:

collection @queues
extends "v1/queues/show"

But I want to have a template for successful response which can embed with queue info, like

{
  "ok":true,
  "data":[@queues' info] (it can be other info too, like @stack info)
}

I am thinking about:

def index
  @queues = Queue.all
  render 'shared/success',locals: { url: 'v1/queues/index', data: @queues }
end

then create a share/success.rabl like:

node(:ok) { true }
child(:data) do
  extend("v1/queues/index",:object =>data)
end

So in every action, I just need pass the path of the rabl file v1/queues/index and instance variable to the shared template shared/success. Is this possible??

1 Answers1

1

To create shared rabl, you can use inheritence (extends) like this:

extends 'path/to/shared/rabl'

You can extend a rabl from inside any other rabl using the above syntax.

See this for more information.

K M Rakibul Islam
  • 33,760
  • 12
  • 89
  • 110