Reputation: 63
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.
Upvotes: 0
Views: 286
Reputation: 169
To set owner with activity you will need to add owner option with tracked in your model like this
tracked owner: :author
Upvotes: 0