I'd like to create JSON like this:
{
"field1": "value-1",
"field2": "value-2",
"actions": {
"edit": "/edit/action/url"
}
}
using rabl. It doesn't work with child
method nor i can't do it with node
- got unknown method error. So, is it possible to create custom child node using rabl template? Say something like this:
collection @datas => :datas
attributes :field1, :field2
child :actions do
node :edit do
edit_datas_path :id
end
end
edit
I choose this one:
node :actions do
actions = {}
actions[:edit] = edit_customer_group_path(:id)
node :foo do
foos = {}
foos[:bar] = "hello"
foos
end
actions
end
But accepted answer below is correct too.
I just stumbled across this issue the other day. This ticket in RABL issues helped me. In your case, I was able to generate proper JSON using:
generated JSON:
Using RABL 0.5.3