0

what am trying to do is to use public activity gem to build a notification system i followed this railscast and everything worked just fine. I have a article and a comment model where users can comment on each others article and the user whom the article belongs to will get notified in their activity feed, but the problem here is that the activity page shows activity of all users, but now i want to show activity only to the specific person whom the article belongs to. Means if a user clicks on the activity button they will only see the activities that happened on there article. Is there any way to accomplish that ? Thanks in advance.

what i had tried till now, but it doesn't seems to work

activities_controller.rb

class ActivitiesController < ApplicationController
 def index
   @activities = PublicActivity::Activity.all.order("created_at desc")
                  .where(trackable_type: "Comment", owner_id: current_user.id, owner_type: "User")
 end
end
Ahmed Reza
  • 293
  • 1
  • 3
  • 19

1 Answers1

0
@activities = PublicActivity::Activity.order("created_at desc")
          .where(trackable_type: "Comment", owner_id: current_user.id, owner_type: "User")

Should work

Artyom Kalmykov
  • 390
  • 1
  • 9
  • no it works but in opposite manner the user which commented can see the activities but the user who created the the post on which comment have been done cant't see the activities that this user had commented on your post... actually sir @artyom Kalmykov am newe to rails...but i think there will be something different instead of current_user.id – Ahmed Reza Oct 20 '15 at 03:18