Stale ActiveRecord Object

J

John Honovich

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
 
M

Mark Bush

John said:
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...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top