Rabl,删除子代的父元素 [英] Rabl, remove parent element of children

查看:100
本文介绍了Rabl,删除子代的父元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谁能帮助我摆脱物品"中的物品"元素

could anyone help me get rid of the "item" element within "items

输出应为:
"list":{ "items":[ { { data1: "test" } , { data2: "test2" } } }

the output should be:
"list":{ "items":[ { { data1: "test" } , { data2: "test2" } } }

collection @list

child :items => :items do
  attributes :place_id
end

child :items do
  child :place do |place|
    extends 'places/place', object: place
  end
end

当前输出:
"list":{ "items":[{ "item":{data1: "test"} "item":{ data2: "test2"}}}

current output:
"list":{ "items":[{ "item":{data1: "test"} "item":{ data2: "test2"}}}

推荐答案

我遇到了同样的问题,这就是解决方案.您可能需要创建名为配置rabl的文件.
config/initializers/rabl.config.rb

I had the same problem and this was the solution. You may need to create the file named to configure rabl.
config/initializers/rabl.config.rb

Rabl.configure do |config|
    config.include_json_root = true
    config.include_child_root =  false
end

这篇关于Rabl,删除子代的父元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆