I\'m trying to render a pretty simple data structure using RABL, but I can\'t figure out how to remove the child root nodes properly. Here are my two templates.
Fir
This is the usual way of removing the root json (rather than specifying object_root: false)
config/initializers/rabl_config.rb
Rabl.configure do |config|
config.include_json_root = false
end
Does moving that to there (and restarting rails), fix it?
On latest versions of Rabl, you have to set this configuration if you want include_root_json
to be false
in all levels.
Rabl.configure do |config|
config.include_json_root = false
config.include_child_root = false
end
Try replacing:
child :files do
extends 'groups/_file'
end
with:
node :files do |group|
group.files.map do |file|
partial 'groups/_file', object: file, root: false
end
end
just putting it out there, in case you want to apply it for a specific child:
child :files, :object_root => false do
extends 'groups/_file'
end