2016-12-29 49 views
2

对于主动记录其工作的罚款Neo4j.rb:as_json如何忽略root?

的ActiveRecord :: Base.include_root_in_json =假

User.first.as_json

=> { "id" => 1, "name" => "Konata Izumi", "age" => 16, 
    "created_at" => "2006/08/01", "awesome" => true} 

当我使用它Neo4j.rb主动节点

Person.first.as_json

=> {"person"=> {" first_name"=>"Kay", "last_name" => "Wood", 
    "email" => "[email protected]" } } 

这就是我要通过API发送repsosne,我不需要这个根元素任何帮助?

回答

2

neo4j文档:

include_root_in_json

当序列ActiveNode和ActiveRel 对象,应该有型号名称中的JSON根。

默认:true

所以你可以只在config/application.rb添加

config.neo4j.include_root_in_json = false 

+0

非常感谢你:) –