From 40ab168a5a91db40042741ac8481255c55373823 Mon Sep 17 00:00:00 2001 From: danielgrippi Date: Fri, 3 Jun 2011 12:20:38 -0700 Subject: [PATCH] DH DG; fix re-liking a post after unliking it --- app/models/notification.rb | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/app/models/notification.rb b/app/models/notification.rb index c6466005a..7fceff2a8 100644 --- a/app/models/notification.rb +++ b/app/models/notification.rb @@ -42,13 +42,17 @@ class Notification < ActiveRecord::Base private def self.concatenate_or_create(recipient, target, actor, notification_type) if n = notification_type.where(:target_id => target.id, - :target_type => target.class.base_class, - :recipient_id => recipient.id, - :unread => true).first - n.actors = n.actors | [actor] + :target_type => target.class.base_class, + :recipient_id => recipient.id, + :unread => true).first - n.unread = true - n.save! + begin + n.actors = n.actors | [actor] + n.unread = true + n.save! + rescue ActiveRecord::RecordNotUnique + nil + end n else make_notification(recipient, target, actor, notification_type)