On Feb 8, 2007, at 11:01 PM, Mark H. Wilkinson wrote:

> 1) the instance of order that the callback updates is never saved.
> 2) if you add a 'save!' call to the callback the total gets updated  
> but
> 'o' then refers to an object that is out of date, so you need to  
> reload
> it before you use the value of 'total'.

1) ActiveRecord does not have an editing  context
2) ActiveRecord does not have an identity map
2) ActiveRecord objects try their best to be stateless (having only  
one bit of state information, which is called new_record?) and  
sometimes it sucks :-)

The problem you described is a design decision of ActiveRecord and  
sadly enough
some very big stuff has got to happen to change that (shall you  
really want to). If you start listing "problems" which stem from the  
fact
that there is no context and no identity map in AR you can prety much  
flood the trac, straight away.

I wish there was a different answer to that. To verify, try the  
following:

folder = Folder.find(4) # let's pretend a Folder has_many :documents
first_document = folder.documents.first
another_copy_of_the_document = Document.find(first_document.id)
first_document.object_id == another_copy_of_the_document.object_id #  
false

You can take a look at this:
http://blog.ianbicking.org/sqlobject-api-redesign.html
and just think of ActiveRecord in terms of "each object has it's own  
editing context,"

-- 
Julian 'Julik' Tarkhanov
please send all personal mail to
me at julik.nl



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to