foobar not loaded yet – in Rails console

Have You seen something like this when working with Rails console?

>> r=Route.find(:first)
=> #<Route:0x9bf9b00 @attributes={[cut...]}>
>> r.points
=> <points not loaded yet>

I usually forgot force Rails to extend models according to its :has_many relations when first time try to reach them in console.

>> r.points(true)
=> [#<Point:0x9bf4ed4 @attributes={"lng"=>"20.8462", "id"=>"460", "lat"=>"52.2478", "route_id"=>"41"}>,
 #<Point:0x9bf4eac @attributes={"lng"=>"20.8521", "id"=>"461", "lat"=>"52.2591", "route_id"=>"41"}>,
 #<Point:0x9bf4e84 @attributes={"lng"=>"20.8421", "id"=>"462", "lat"=>"52.2626", "route_id"=>"41"}>,
 #<Point:0x9bf4e5c @attributes={"lng"=>"20.8381", "id"=>"463", "lat"=>"52.2568", "route_id"=>"41"}>,
 #<Point:0x9bf4e34 @attributes={"lng"=>"20.8383", "id"=>"464", "lat"=>"52.2528", "route_id"=>"41"}>,
 #<Point:0x9bf4e0c @attributes={"lng"=>"20.8414", "id"=>"465", "lat"=>"52.2506", "route_id"=>"41"}>,
 #<Point:0x9bf4de4 @attributes={"lng"=>"20.8409", "id"=>"466", "lat"=>"52.2489", "route_id"=>"41"}>,
 #<Point:0x9bf4dbc @attributes={"lng"=>"20.8458", "id"=>"467", "lat"=>"52.2476", "route_id"=>"41"}>]
>>

Much better now…

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.