Skip to main content
Ask A Question
Notifications
You’re not receiving notifications from this thread.
Subscribe

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

General • Asked by Wesly Mezarina

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 %>

Login or Create An Account to join the conversation.

Subscribe to the newsletter

Join 30,005+ developers who get early access to new screencasts, articles, guides, updates, and more.

    By clicking this button, you agree to the GoRails Terms of Service and Privacy Policy.

    More of a social being? We're also on Twitter and YouTube.