lib/audited/audit.rb in notifiably_audited-0.0.2 vs lib/audited/audit.rb in notifiably_audited-0.0.3
- old
+ new
@@ -10,15 +10,18 @@
belongs_to :auditable, :polymorphic => true
belongs_to :user, :polymorphic => true
belongs_to :associated, :polymorphic => true
before_create :set_version_number, :set_audit_user
+
+ after_save :notify
cattr_accessor :audited_class_names
self.audited_class_names = Set.new
- attr_accessible :action, :audited_changes, :comment, :associated
+ attr_accessible :action, :audited_changes, :comment,
+ :associated, :receiver_id, :checked, :meta,:title
end
# Returns the list of classes that are being audited
def audited_classes
audited_class_names.map(&:constantize)
@@ -94,9 +97,19 @@
self.version = max + 1
end
def set_audit_user
self.user = Thread.current[:audited_user] if Thread.current[:audited_user]
+ p self.user
nil # prevent stopping callback chains
end
+ #====== beck added for notifiable ====
+ def notify
+ PrivatePub.publish_to("/notifiably_audited/" + self.receiver_id.to_s,
+ title: self.title,
+ comment: self.comment,
+ id: self.id)
+ end
+ #========================================
+
end
end