after_update woes

Hey everyone.

I am trying to run a an external process after a update from the view.
I currently have it set up to run after_update but it seems that the
transaction it uses hasn't been closed at that point. My process is
supposed to check some variables in the database and change a specific
column in the database. Now because the transaction hasn't been closed
it results in a deadlock. Does any one have a good work around to
achieve this?

InnerSparkMedia wrote:

I am trying to run a an external process after a update from the view.
I currently have it set up to run after_update but it seems that the
transaction it uses hasn't been closed at that point. My process is
supposed to check some variables in the database and change a specific
column in the database. Now because the transaction hasn't been closed
it results in a deadlock. Does any one have a good work around to
achieve this?

One hack is to put something like "sleep 2" at the beginning of the
external process. Or call the external process from your controller.
Or change the transaction visibility level of your external-process
DB connection.

But it'd be nice if transaction calls could again take model instance
parameters, allowing implementation of an after_commit callback.

How do you go about calling say a model method from the controller?
Because my call to the external process is defined in the model.

or just the external process?

Also when dose a transaction end?

InnerSparkMedia wrote:

Also when dose a transaction end?

You can put your call to the external process after the
end of the transaction "do" block (or after the save for
automatic transaction wrappings).

Just call Model.method if the process can be started by a
class method of Model.

Thank you for your help. They did it. What I had to do was place
@model.method in the if saved statement and it worked.