From 162303db37bc263b7c49466eb17cde3e6c9f433c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jonne=20Ha=C3=9F?= <me@jhass.eu>
Date: Sun, 28 Dec 2014 20:36:51 +0100
Subject: [PATCH] Enable Rails 5 behavior for exceptions in after_commit
 callbacks

---
 app/models/reshare.rb | 2 +-
 config/application.rb | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/app/models/reshare.rb b/app/models/reshare.rb
index 869d73351a..7e8fac45b5 100644
--- a/app/models/reshare.rb
+++ b/app/models/reshare.rb
@@ -18,7 +18,7 @@ class Reshare < Post
   end
 
   after_commit :on => :create do
-    self.root.update_reshares_counter
+    self.root.update_reshares_counter if self.root.present?
   end
 
   after_destroy do
diff --git a/config/application.rb b/config/application.rb
index b84576c79b..4d579a5423 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -89,5 +89,8 @@ module Diaspora
       g.template_engine :haml
       g.test_framework  :rspec
     end
+
+    # Will be default with Rails 5
+    config.active_record.raise_in_transactional_callbacks = true
   end
 end
-- 
GitLab