Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When do transactions start when using (restful) rails

Is it the case that the entire restful verb is under a single all encompassing transaction? That is to say, if I raise a Error in the validation or callbacks at any point in the handling of a UPDATE, DELETE, or CREATE operation, is every database operation that I may have performed in previous callbacks also rolled back? Succinctly, does raising a Error on any callback or validation make it such that no change at all occurs in the database for that verb action?

like image 316
Stephen Cagle Avatar asked Sep 23 '08 22:09

Stephen Cagle


1 Answers

Is it the case that the entire restful verb is under a single all encompassing transaction?

No

if I raise a Error in the validation or callbacks at any point in the handling of a UPDATE, DELETE, or CREATE operation, is every database operation that I may have performed in previous callbacks also rolled back?

No.

does raising a Error on any callback or validation make it such that no change at all occurs in the database for that verb action?

No.

If you desire this behaviour you can either explicitly create transactions in your controller (see the examples provided by other users), or use an around_filter to attach the behaviour to all your restful actions.

like image 175
Orion Edwards Avatar answered Oct 05 '22 02:10

Orion Edwards