SwitchUp SwitchUp Ranked Best Coding Bootcamps 2025

Rescue ActiveRecord transaction block and also get error messages

Altcademy Team wrote on 7 February 2018

begin ActiveRecord::Base.transaction do user.save! # will raise exception if error exists end rescue ActiveRecord::RecordInvalid => exception puts exception.message # prints error message end


Trusted by

Students and instructors from world-class organizations

Join the upcoming Cohort #111

Enroll for March 2nd, 2026