From abb29aae4b519f227c44e6d6e51bb29112b7dc02 Mon Sep 17 00:00:00 2001 From: Matchu Date: Tue, 22 Feb 2011 18:45:53 -0500 Subject: [PATCH] hopefully raise more descriptive error message when contribution fails to save --- app/models/user.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/models/user.rb b/app/models/user.rb index 9abe043b..4e422d09 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -23,7 +23,13 @@ class User < ActiveRecord::Base self.points += new_points Pet.transaction do pet.save! - new_contributions.each(&:save!) + new_contributions.each do |contribution| + begin + contribution.save! + rescue ActiveRecord::RecordNotSaved => e + raise ActiveRecord::RecordNotSaved, "#{e.message}, #{contribution.inspect}, #{contribution.valid?.inspect}, #{contribution.errors.inspect}" + end + end save! end new_points