Episode 73 of Ryan Bate’s great series of screencasts shows an example
of using fields_for to create a new record containing two models. I’m
trying to repeat his result but alway get and error from this line:
<% fields_for "ferry[scheduled_port_attributes][]", scheduled_port
do |sp_form| %>
In the rails cast, this returns an array of scheduled_port_attributes,
but instead I get a hash with “3” as a key:
{“commit”=>“Save”,
“ferry”=>{ “scheduled_port_attributes”=>{“3”=>{“departs(4i)”=>“21”,
“departs(5i)”=>“29”,
“arrives(1i)”=>“2007”,
“arrives(2i)”=>“10”,
“port_id”=>“2”,
“arrives(3i)”=>“12”,
“arrives(4i)”=>“21”,
“departs(1i)”=>“2007”,
“arrives(5i)”=>“29”,
“departs(2i)”=>“10”,
“departs(3i)”=>“12”}},
“id”=>“1”}}
Am I missing something? I’m on edge rails. Does that matter?