[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Stale ActiveRecord Object

John Honovich

3/23/2008 6:42:00 PM

In a non-rails application, I am using AR as my ORM.

I am using an AR object in multiple places in my application. At one
point, I update the AR object and commit the changes to the db.

Later, I access that AR object and I need to check the value of an
attribute. While this attribute has been updated in mysql, the AR
object shows the old value.


Is this an issue of poor design on my part? Should I take a different
approach or is there some way to update/refresh an AR object?

Thanks,

John
--
Posted via http://www.ruby-....

1 Answer

Mark Bush

3/23/2008 6:46:00 PM

0

John Honovich wrote:
> Is this an issue of poor design on my part? Should I take a different
> approach or is there some way to update/refresh an AR object?

Call #reload on the object.

If you have more than one thread/process accessing the database then you
still have a race condition...

--
Posted via http://www.ruby-....