Reputation: 6189
The following parameters are being posted
Parameters: {
"orig_id"=>47,
"terms_accepted"=>true,
"email"=>"[email protected]",
"name"=>"firstname",
"surname"=>"surname",
"kids"=>[
{"school"=>"Faraway", "rate"=> "89"},
{"school"=>"Transfer", "rate"=> "23"},
{"school"=>"Bike", "rate"=>"4"}]
}
However, the rails controller action, defined as follows only creates the parent record, but not the related ones:
parent = params[:parent]
@parent = Parent.new(orig_id: parent['orig_id'], terms_accepted: parent['terms_accepted'], email: parent['email'], name: parent['name'], surname: parent['surname'])
@parent.save
kids = params[:kids]
kids each do |kid|
@kid = Kid.new(school: kid['school'], rate: kid['rate'], parent_id: @parent.id)
@kid.save
end
where is the syntax wrong?
Upvotes: 0
Views: 24