2008-04-12
Reloading the Association
关键字: rails
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
>> 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
发表评论
最近加入圈子
最新评论
-
又一个DynamicDao
呵呵,老大你写的东东,不错。我学习了(刚刚一新手哈!) 不过,要是再写一点注释就 ...
-- by heshencao -
又一个DynamicDao
实现Query Annotation的主要代码如下: public class ...
-- by studyworks -
又一个DynamicDao
Norther 写道 没看出来dynamic在哪?就是自己实现了一套Crite ...
-- by studyworks -
又一个DynamicDao
没看出来dynamic在哪?就是自己实现了一套Criteria,而且Generi ...
-- by Norther







评论排行榜