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

前端 未结 2 1352
花落未央
花落未央 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 06:56

    nesquena posted solution on github: https://github.com/nesquena/rabl/issues/436

    collection @posts
    
    node :categories do |p|
      p.categories.map do |c| 
        partial("categories/show", :object => c).merge(:post_attr => p.post_attr)
      end
    end
    

提交回复
热议问题