Unable to set owner in Public Activity Gem

274 views Asked by At

I have a social media app, having users along with question/response model in my rails app. I am using pubic activity gem in this application. I have followed the steps as per the railscast. I have also followed this documentation below:

https://github.com/chaps-io/public_activity#setup

In my activities.json response am getting:

"owner_id":null,"owner_type":null

Activites_controller.rb file:

class ActivitiesController < ApplicationController
     def index
        @activities = PublicActivity::Activity.order("created_at desc")

    respond_to do |format|
      format.html
      format.json {render json: @activities.to_json()}
    end
    end 
end

Acivities view file

<h1>Activities</h1> 
<% @activities.each do |activity|%>   
 <div class="activity">
   <%= link_to activity.owner.name, activity.owner if activity.owner %>
   <%= render_activity activity %>  
 </div>
<% end %>

Can anyone please help me figure out what the issue is?

Thanks.

1

There are 1 answers

0
Sujay Gavhane On

To set owner with activity you will need to add owner option with tracked in your model like this

tracked owner: :author