3

I've just started playing with the stream-rails gem, and have the flat and user feeds working more or less.

One of my models is being made into an activity when an instance is created - even though my activity_should_sync? is implemented to return false.

It seems anything inside this method is not run at all, including puts. Appreciate any advice

class Post < ActiveRecord::Base
  ...
   include StreamRails::Activity
   as_activity

  def activity_should_sync? 
    false
  end

  def activity_object
    self
  end
fool-dev
  • 7,671
  • 9
  • 40
  • 54
dale
  • 43
  • 3

1 Answers1

1

The activity_should_sync? method is not released in the latest gem yet (upcoming 2.4). The 2.4 gem will be released on rubygems next week. In the meantime you can install the latest version from Github directly.

Tommaso Barbugli
  • 11,781
  • 2
  • 42
  • 41
  • Thank you so much! I thought I was going crazy! – dale Jan 22 '16 at 05:42
  • Has this been implemented...? Apologies if it has - I've downloaded the new gem & it seems not yet – dale Feb 18 '16 at 04:09
  • what version did you get from RubyGem? – Tommaso Barbugli Feb 18 '16 at 12:01
  • `Fetching: stream-ruby-2.2.5.gem (100%) Successfully installed stream-ruby-2.2.5 Fetching: stream_rails-2.4.0.gem (100%) Successfully installed stream_rails-2.4.0` It seems my activity_should_sync is not being called at all when the model instance is created. If you have any working examples of this I would most appreciate the link. Thank you! – dale Feb 19 '16 at 02:48
  • Disregarding above... My activity_should_sync **is** being called on instance creation, and works as expected with self.published (false) being returned. However when the self.published is changed to true later on, an activity is not being created. Do I need to create a new activity manually in this situation..? Thank you as always – dale Feb 19 '16 at 03:32
  • @dale the sync policy adds activities to the APIs only when the model is created, not when is saved. You can change that if you create your own SyncPolicy. My suggestion is to create a separate question for it. – Tommaso Barbugli Feb 19 '16 at 13:15
  • Many thanks for your patience. I will create a Published model in order to implement this :) – dale Feb 22 '16 at 03:26