Nested Attributes Behavior

This is sample how to use nested attributes behavior.
  
  
  children = { 
        children_attributes: [
         { id: 2, name: 'Larry',parent_id:1 },
         { id: 3, name:'Curly',parent_id:1 },
         { id:4, name: 'Moe',parent_id:1 }
        ]
       }
  
To Initialize:
  
  
 children = { children_attributes: [] }
  
To Insert:
  
  
 children[:children_attributes] << { :id => 5, :name => "Oliver" }
  

No comments:

Post a Comment