Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby-on-rails-4/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 4 同步冗余mongoid文档_Ruby On Rails 4_Graph_Mongoid_Data Synchronization_Redundancy - Fatal编程技术网

Ruby on rails 4 同步冗余mongoid文档

Ruby on rails 4 同步冗余mongoid文档,ruby-on-rails-4,graph,mongoid,data-synchronization,redundancy,Ruby On Rails 4,Graph,Mongoid,Data Synchronization,Redundancy,我决定对一个知识图建模,其中一个节点=一个文档,一个边=节点中嵌入的一个文档。此图支持定向边,我决定在双向节点中复制一条边 class Tag includes Mongoid::Document field :name embeds_many :links, class_name: 'TagLink', inverse_of: :parent_node class TagLink includes Mongoid::Document embedded_in :par

我决定对一个知识图建模,其中一个节点=一个文档,一个边=节点中嵌入的一个文档。此图支持定向边,我决定在双向节点中复制一条边

class Tag
  includes Mongoid::Document
  field :name  

  embeds_many :links, class_name: 'TagLink', inverse_of: :parent_node

class TagLink
  includes Mongoid::Document
  embedded_in :parent_node, class_name: 'Tag', inverse_of: :link
  belongs_to :child_node, class_name: 'Tag'
现在,我的用户版主可以创建新标签,并为此标签指定链接

我的POST/PATCH请求中的参数如下所示

tag: {name: "Rails", links: [
  {child_name: "Ruby", child_node: "abhkdfjgksgdf000023d415", bidirectional_edge: true, ...}, 
  {child_name: "Server Programming", bidirectional_edge: true, ...}
]}
确保同步顺利完成的最佳方法是什么?我不确定我真正想要的行为,但基本上上面的帖子应该

  • 创建新标记“Rails”
  • 更新标记“Ruby”,“Server Programming”以添加指向“Ruby”的链接,因为
    双向边缘设置为true
  • 如果在更新链接时出现问题,理想的做法可能是回滚任何更改并显示有错误的视图(如果回滚太困难,那么可能只显示问题列表)
我目前正在尝试推出我自己的实现,但也许你有任何宝石,提示,或者你可以找到这个更快,更干净的比我会做