I am going over Public Activity Gem Railscast Vid. (http://railscasts.com/episodes/406-public-activity)
My current DB looks/stores everything but the recipient_id....it shows up as nil
#<PublicActivity::Activity id: 108, trackable_id: 133, trackable_type: "Relationship",
owner_id: 1, owner_type: "User", key: "relationship.create", parameters: {},
recipient_id: nil, recipient_type: nil, created_at: "2013-06-16 07:37:28",
updated_at: "2013-06-16 07:37:28">
I would like the recipient_id to be the user who the action is being performed on....
Ex.
If I like Tom's Post.....I would like Tom's ID to become the recipient_id & I'll be the owner_id.
I have currently set a recipient ID....using the code in my Likes Controller....but it only sets the recipient Id to current user....which is not what i want :(
LIKES CONTROLLER
class Like < ActiveRecord::Base
include PublicActivity::Model
tracked except: :destroy, owner: ->(controller, model) { controller && controller.current_user }
**tracked except: :destroy, recipient: ->(controller, model) { controller && controller.current_user }**
attr_accessible :dailypost_id, :user_id
belongs_to :user
belongs_to :dailypost
default_scope order: 'likes.created_at DESC'
end
Do I need to create a method or something. Please help.....new to rails
tracked recipient: ->(controller, model) { model && model.user }
assuming Tom is the user of tracked object. Otherwise change model.user
as per your application
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With