Track only when owner is known

65 views
Skip to first unread message

Thomas Buyle

unread,
Mar 11, 2016, 5:09:24 AM3/11/16
to Public Activity
Hello,

I tracked variousModel in my app, assigning the current user as owner with
   owner: ->(controller, model) { controller && controller.current_user}

These models can also be updated or created by various callbacks and shceduled task in my app. In such case, owner is nil (as expected)

I'd like to avoid tracking these actions, so that only actions when owner are actually tracked / registred in the DB.

Any idea on how to do so ?

Andy Rose

unread,
Apr 18, 2016, 12:57:05 PM4/18/16
to Public Activity
I'd be interested in knowing about this.....

Jakub Okoński

unread,
Apr 18, 2016, 2:37:26 PM4/18/16
to Andy Rose, Public Activity
You can use the `:on` option on `#tracked`, http://www.rubydoc.info/gems/public_activity/PublicActivity/Tracked/ClassMethods#tracked-instance_method.

```
# app/models/article.rb
tracked on: {update: :published?}
```

--
You received this message because you are subscribed to the Google Groups "Public Activity" group.
To unsubscribe from this group and stop receiving emails from it, send an email to public-activi...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Andy Rose

unread,
Apr 18, 2016, 3:19:11 PM4/18/16
to Jakub Okoński, Public Activity
Cool, thanks! 
Reply all
Reply to author
Forward
0 new messages