Có nên gọi ActiveRecord::Rollback với rescue trong transaction rails?

Có nên gọi ActiveRecord::Rollback với rescue trong transaction rails?

Khi sử dụng transaction trong RoR, có lúc ta không cần phải gọi câu lệnh ActiveRecord::Rollback , cũng có lúc ta phải gọi nó. Xét ví dụ: self.transaction do first_operation begin second_operation call_other_function rescue Exception => e #deal with the error raise ActiveRecord::Rollback #force a rollback end end Nếu bỏ raise ActiveRecord::Rollback : Mọi thay đổi tới DB xảy ra ở second_operation và call_other_function đều được r...