How to add parent attributes inside its children in rabl template (when parent is an array)?

前端 未结 2 1355
花落未央
花落未央 2021-01-15 06:46

How to add parent attributes inside its children in rabl template? To do something like this:

  some_root_attr: {
    attr_a: \'rgtr\',
    parent: [
      {         


        
2条回答
  •  一个人的身影
    2021-01-15 07:01

    object @obj
    attributes :attr_a
    
    child :parents do
      attributes :attr_1
      parent = root_object.dup
      child :child do 
        attributes :attr_3
        node(:attr_from_parent_array_member) { parent.attr_from_parent_array_member }
      end
    end
    

    NB haven't tested

提交回复
热议问题