We are looking for a command to delete multiple records within Rails transaction
. To make it trigger within transaction
, we used destroy_all!
and delete_all!
and received method not defined
error. What's the right delete command (or right way) for multiple records which triggers in Rails transaction?
No, there are no methods called delete_all!
or destroy_all!
. See the documentation.
Use delete_all
or destroy_all
instead. These methods will raise ActiveRecord errors if deletion fails. It means your transaction will be rolled back in case of errors as you expected.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With