没有使用activity_notification获取通知

问题描述 投票:0回答:1

我有一个应用程序使用gem acts_as_follower用户互相关注。我也使用activity_notification通知用户有关该应用程序的信息。在acts_as_follower模型中,我有:

follow.rb

class Follow < ActiveRecord::Base

  extend ActsAsFollower::FollowerLib
  extend ActsAsFollower::FollowScopes

  # NOTE: Follows belong to the "followable" interface, and also to followers
  belongs_to :followable, :polymorphic => true
  belongs_to :follower,   :polymorphic => true

  def block!
    self.update_attribute(:blocked, true)
  end

  # acts_as_notifiable configures your model as ActivityNotification::Notifiable
  # with parameters as value or custom methods defined in your model as lambda or symbol.
  # The first argument is the plural symbol name of your target model.
  acts_as_notifiable :users,
  # Notification targets as :targets is a necessary option
  # Set to notify to author and users commented to the article, except comment owner self
    targets: ->(follow, key) {
      ([follow.user] + follow.user.to_a - [follow.user]).uniq
    }

  tracked: true
  # Path to move when the notification is opened by the target user
  # This is an optional configuration since activity_notification uses polymorphic_path as default


end

但是我没有收到通知。我应该试试

targets: ->(current_user, key) {
  ([current_user.follow] + current_userfollow.to_a - [current_user.follow]).uniq
}

有人曾经使用过这些宝石吗?如何才能使此通知正常工作?

我正在为用户使用设计。

谢谢!!

ruby-on-rails ruby-on-rails-4 notifications rubygems
1个回答
0
投票

通知目标([follow.user] + follow.user.to_a - [follow.user]).uniq的配置始终为空白数组。

© www.soinside.com 2019 - 2024. All rights reserved.