Reloading the Association

Notice that the second time I invoke the association via user, the object_id remains the same. The related object has been cached. However, passing true to the accessor reloads the relationship and I get a new instance.

>> ts = Timesheet.find :first
=> #<Timesheet:0x3454554 @attributes={“updated_at”=>”2006-11-21
05:44:09”, “id”=>”3”, “user_id”=>”1”, “submitted”=>nil,
“created_at”=>”2006-11-21 05:44:09”}>
>> ts.user.object_id
=> 27421330
>> ts.user.object_id
=> 27421330
>> ts.user(true).object_id
=> 27396270

你可能感兴趣的:(Rails)