Ask A Question


You’re not receiving notifications from this thread.

How do i show a specific book and show all the activity that a uniq user provided with the public_activity gem?

Wesly Mezarina asked in General

I'm able to show a stream of activity for each user in their profile. What I'm trying to figure out is how i can have a book show one time with the activity that a specific user provided on the side like Favorite, Liked and so on rather then showing the same book multiple times with the activity next to it. How do i show a specific book and show all the activity that a uniq user provided?

This is my UsersController. I use the @activities to show the users activity.

 class UsersController < ApplicationController
  def show
   @user = User.friendly.find(params[:id])
   @activities = PublicActivity::Activity.order("created_at desc")
      .where(owner_id:, owner_type: "User")

This is my _activity.html.erb page

 <% @activities.each do |activity| %>
  <%= link_to image_tag(activity.trackable.cover_image.url{:large}),>
  <%= render_activity activity %>
 <% end %>
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 80,973+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    Screencast tutorials to help you learn Ruby on Rails, Javascript, Hotwire, Turbo, Stimulus.js, PostgreSQL, MySQL, Ubuntu, and more.

    © 2024 GoRails, LLC. All rights reserved.