-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
>> foo = Route.first
MOPED: 127.0.0.1:27017 QUERY database=gocheap_development collection=routes selector={"$query"=>{}, "$orderby"=>{:_id=>1}} flags=[:slave_ok] limit=-1 skip=0 fields=nil (0.7820ms)
#<Route ... >
>> foo.flight_codes.detect
{|flight_code| flight_code.flight_number == "6011"}.aircraft = "Boeing"MOPED: 127.0.0.1:27017 QUERY database=gocheap_development collection=flight_codes selector={"route_id"=>"50190e164c4c6c958866b1f7"} flags=[:slave_ok] limit=0 skip=0 fields=nil (1.8277ms)
"Boeing"
>> foo.flight_codes.detect{|flight_code| flight_code.flight_number == "6011"}
.aircraft
MOPED: 127.0.0.1:27017 QUERY database=gocheap_development collection=flight_codes selector=
""
So flight_codes are not linked to the route properly in this case. Aircraft is not changed and flight_codes are requested two times.
So I have to do an additional '.to_a'.
>> foo = Route.first
MOPED: 127.0.0.1:27017 QUERY database=gocheap_development collection=routes selector={"$query"=>{}, "$orderby"=>{:_id=>1}} flags=[:slave_ok] limit=-1 skip=0 fields=nil (0.5507ms)
#<Route ... >
>> foo.flight_codes.to_a.detect{|flight_code| flight_code.flight_number == "6011"}.aircraft = "Boeing"
MOPED: 127.0.0.1:27017 QUERY database=gocheap_development collection=flight_codes selector={"route_id"=>"50190e164c4c6c958866b1f7"}
flags=[:slave_ok] limit=0 skip=0 fields=nil (1.9109ms)
"Boeing"
>> foo.flight_codes.detect
{|flight_code| flight_code.flight_number == "6011"}.aircraft
"Boeing"