W
wrex
I've got an application where I need to do three things in an atomic
transaction:
1) move a file from one subdirectory to another (in the same
filesystem)
2) update an activerecord object with the resulting path to the the
new location
3) call the save method on the activerecord object.
If any one of these three operations fails, I need to ensure the file
remains in it's original location (or is moved back to it's original
location) and that the database remains in it's original state.
What's a clean, idiomatic, and robust method in ruby to accomplish
this? (My table supports transactions, but how do I make the file
move/rename part of the transaction?)
Many thanks for any help.
transaction:
1) move a file from one subdirectory to another (in the same
filesystem)
2) update an activerecord object with the resulting path to the the
new location
3) call the save method on the activerecord object.
If any one of these three operations fails, I need to ensure the file
remains in it's original location (or is moved back to it's original
location) and that the database remains in it's original state.
What's a clean, idiomatic, and robust method in ruby to accomplish
this? (My table supports transactions, but how do I make the file
move/rename part of the transaction?)
Many thanks for any help.