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

Ask A Question

Notifications

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: @user.id, owner_type: "User")
  end
 end

This is my _activity.html.erb page

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

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

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

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

    logo Created with Sketch.

    Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

    © 2020 GoRails, LLC. All rights reserved.