acts_as_notifiable 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
@@ -30,8 +30,8 @@ module ActsAsNotifiable
|
|
30
30
|
private
|
31
31
|
|
32
32
|
def self.polymorphic_queries(notifications, type, type_id)
|
33
|
-
notifications = notifications.where(
|
34
|
-
notifications = notifications.where(
|
33
|
+
notifications = notifications.where(parent_type: type)
|
34
|
+
notifications = notifications.where(parent_id: type_id) if type_id
|
35
35
|
notifications
|
36
36
|
end
|
37
37
|
|
@@ -61,7 +61,7 @@ module ActsAsNotifiable
|
|
61
61
|
def create_notification
|
62
62
|
if self.class.polymorphic?
|
63
63
|
polymorphic_array = polymorphic_sender
|
64
|
-
Notification.
|
64
|
+
Notification.find_or_create_by_user_id_and_notifiable_id_and_notifiable_type_and_parent_type_and_parent_id(self.user_id, self.id, self.class.to_s, polymorphic_array[0], polymorphic_array[1])
|
65
65
|
else
|
66
66
|
Notification.find_or_create_by_user_id_and_notifiable_id_and_notifiable_type(self.user_id, self.id, self.class.to_s)
|
67
67
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
class Notification < ActiveRecord::Base
|
2
2
|
|
3
|
-
attr_accessible :user_id, :notifiable_id, :notifiable_type, :delivered, :
|
3
|
+
attr_accessible :user_id, :notifiable_id, :notifiable_type, :delivered, :parent_id, :parent_type
|
4
4
|
|
5
5
|
# Validations
|
6
6
|
validates_presence_of :user_id, :notifiable_id, :notifiable_type
|