acts_as_tree - parent reference is outdated?

I'm experiencing some unexpected weirdness with acts_as_tree.

class Category < ActiveRecord::Base   acts_as_tree   has_many :variations end

def variations   # some code that returns the parent category variations if we have none end

pc = pc.variations << "foo" cc = cc.parent = pc

So far so good ...

pc.variations .... ["foo"] cc.variations .... ["foo"]


pc.variations ... <--- that's expected cc.variations ... ["foo"] <-- UNEXPECTED!! cc = Category.find 2 cc.variations ... <-- again, expected

What's going on here? The reference to pc and cc.parent are also not equal (before reloading even) but I guess that's just how AR works. I'm used to Hibernate returning the same reference.

Any suggestions or explanations?



Are you sure its not just that the reference to parent is out-dated? Maybe this is just a feature of ActiveRecord? If belongs_to type relationships are just copies of what's in the database at the time that would explain it. It would also explain why re-retrieving the record produces the expected result.