我想我可能已经发现了Vestal版本中的一个错误(http://github.com/laserlemon/vestal_versions) - 似乎revert_to
的行为取决于我过去使用相同对象所做的回复。这是一个例子:
>> a = Annotation.find(1384)
=> #<Annotation id: 1384, body: "Just hanging out -- \"playing possum\" -- at the stor...", last_updated_by_id: 3, created_by_id: 3, song_id: 30, deleted_at: nil, created_at: "2009-09-06 01:56:55", updated_at: "2009-10-27 22:02:35", referent: "in the spot playing possum\nDebating my destination,...", vote_score: 0>
>> a.revert_to(9)
=> 9
>> a.body
=> #<RDiscount:0x21cf7bc @filter_styles=true, @smart=true, @fold_lines=nil, @filter_html=nil, @text="Just hanging out -- \"playing possum\" -- at the store, lacing up the new Nikes, trying to decide where to go for dinner">
>> a = Annotation.find(1384)
=> #<Annotation id: 1384, body: "Just hanging out -- \"playing possum\" -- at the stor...", last_updated_by_id: 3, created_by_id: 3, song_id: 30, deleted_at: nil, created_at: "2009-09-06 01:56:55", updated_at: "2009-10-27 22:02:35", referent: "in the spot playing possum\nDebating my destination,...", vote_score: 0>
>> a.revert_to(8)
=> 8
>> a.body
=> #<RDiscount:0x21b5a10 @filter_styles=true, @smart=true, @fold_lines=nil, @filter_html=nil, @text="I.e. just hanging out -- \"playing possum\" -- in the living room, lacing up the new Nikes, trying to decide where to go for dinner">
>> a.revert_to(:last)
=> 11
>> a.revert_to(9)
=> 9
>> a.body
=> #<RDiscount:0x21b5a10 @filter_styles=true, @smart=true, @fold_lines=nil, @filter_html=nil, @text="I.e. just hanging out -- \"playing possum\" -- in the living room, lacing up the new Nikes, trying to decide where to go for dinner">
即如果我revert_to(9)
来自新加载的注释,则body字段包含一个RDiscount对象,其文本开始“Just hanging out - \”播放负鼠\“ - 在商店”(这就是身体是版本9)
但是,如果我从新加载的注释中恢复为revert_to(8)
,请检查注释的正文revert_to(:last)
和revert_to(9)
,注释的正文在版本9中是错误的(它将匹配版本8的注释主体
有什么想法吗?
答案 0 :(得分:3)
这不是vestal_versions中的错误,在版本更改后,它不会重新加载您的关联。
假设您的Annotation
拥有您RDiscount
的ID,则会发生以下情况:
Annotation
“a”RDiscount
ID为x。RDiscount
ID更改为y。a.body
,导致rails加载ID为y的RDiscount
对象。:last
,RDiscount
ID再次更改为x。a.body
,但rails已经加载了RDiscount
对象并将返回此对象。