Ok thanks
> It's definitely a synchronous call, in that the database has received the
> INSERT/UPDATE command before #save[!] returns.
>
> But, if you're in a transaction you won't be able to see the data in any
> other context until the database receives COMMIT when the transaction block
> closes.
So just confirming:
Suppose i Have
ARObject, ARObjectObserver, and ARObjectHistory (which is an audit
recording all history changes of an ARObject)
So in rough pseudo code,
#==ARObject
class ARObject < ActiveRecord::Base
has_many ARObjectHistories
def action()
ARObject.transaction do
self.status = UPDATED_STATUS
self.save!
self.ar_object_histories(true).find(# latest one just created)
# Can't find it... Even in NaviCat, even with the reload of
associations...
end
end
def add_history!(blah)
obj_hist = ARObjectHistory.new(blah)
obj_hist.ar_object = self
obj_hist.save!
end
end
# ==ARObjectObserver
class ARObjectObserver < ActiveRecord::Observer
def before_update(record)
blah = # History info etc..
record.add_history!(blah)
end
end
Is that right? I won't be able to see the latest history just created
from within the same transaction until it completes?
Thanks
Chris
P.s. yes to using MySQL :(
--
You received this message because you are subscribed to the Google Groups "Ruby
or Rails Oceania" 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/rails-oceania?hl=en.