Gem`activation_notification`在被活动记录触发后不会创建新记录

时间:2018-02-05 09:35:03

标签: ruby-on-rails activerecord rubygems

根据文档配置后,gem activity_notification没有创建/触发。我试图在用户创建评论或回复现有评论的情况下创建通知,但不创建/触发gem。请帮我弄清楚原因。

这是我的代码

模型用户

class User < ApplicationRecord
  audited

  with_options dependent: :destroy do |assoc|
    assoc.has_many :forums, class_name: 'Communication::Forum'
    assoc.has_many :favorited_forums, class_name: 'Communication::FavoritedForum'
    assoc.has_many :comments
    assoc.has_many :likes
  end

  acts_as_target
end

模型论坛

class Communication::Forum < ApplicationRecord
  audited
  belongs_to :user

  acts_as_commentable

  has_many :likes, as: :likeable
  has_many :favorited_forums, class_name: "Communication::FavoritedForum"

end

型号评论

class Comment < ActiveRecord::Base
  audited
  acts_as_nested_set scope: [:commentable_id, :commentable_type]
  belongs_to :commentable, polymorphic: true

  acts_as_notifiable :users,
    targets: ->(comment, key) {
      ([comment.commentable.user] + [comment.user]).uniq
    }

end

0 个答案:

没有答案