在Stream Rails中的两个Feed组中创建活动

问题描述

我正在使用Stream Rails构建具有供稿的应用。 user有一些page,其他用户可以关注。为此,我创建了一个page供稿组。这是我的Post模型-

class Post < ApplicationRecord
  belongs_to :page
  belongs_to :author,class_name: "User"
  has_one :post_item,inverse_of: :post

  accepts_nested_attributes_for :post_item
  include StreamRails::Activity
  as_activity


  def activity_object
    self.post_item
  end

  def activity_actor
    self.author
  end
end

但是,帖子转到用户的供稿。如何将其转到page供稿组?我浏览了github代码,我想必须重写activity_owner_Feed吗?但我也希望作者列出他们创建的所有帖子。因此,帖子也必须位于user供稿中。

这是我的控制器中的相应代码-

    # this method creates the post
    # This puts the post in user Feed
    # I also want to add the post to page Feed
    def create
        @post = current_user.posts.build post_params
        @post.save

        render json: { success: true }
      end

      # show all posts of a user

      def show
        Feed = StreamRails.Feed_manager.get_user_Feed(current_user.id)
        enricher = StreamRails::Enrich.new
        results = Feed.get()['results']
        @activities = enricher.enrich_activities(results)

        render json: { activity: @activities }
      end

对应路线-

 post 'post/create'
 post 'post/show'

解决方法

您需要覆盖activity_notify并返回一组供稿,以进行通知。 它将翻译为to target in the generated activity

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...