I have an ActiveRecord transaction that works some times and fails some
times. I’ve narrowed it down to where the failure depends on the
inclusion of an empty method from a library object. By ‘empty’, I mean
I’ve removed all code from the method, so the problem is related to
making the method call (i.e. it’s not in my code). Here’s some pseudo
# saving class B obj succeeds when this next method is commented
# but it fails with ‘update violates foreign key constraint’ when
this method is called
@objectOfClassB.refToA = objectOfClassA.id
It behaves as if the second save cannot see the object created in the
first save, even though they both happen within the transaction.
Why would the inclusion of the unrelated, empty method ‘donothing’ have
such an effect?