Skip to content
Snippets Groups Projects
Commit 5820bc36 authored by Israel Barreto Sant'Anna's avatar Israel Barreto Sant'Anna
Browse files

Added trackable_type to activity serializer and fixed user.activities

parent a37cf8f5
No related branches found
No related tags found
No related merge requests found
...@@ -142,7 +142,7 @@ class User < ApplicationRecord ...@@ -142,7 +142,7 @@ class User < ApplicationRecord
# return an array of PublicActivity::Activity # return an array of PublicActivity::Activity
def activities def activities
condition = '(owner_type = :type AND owner_id = :id) OR (recipient_type = :type AND recipient_id = :id)' condition = '(owner_type = :type AND owner_id = :id) OR (recipient_type = :type AND recipient_id = :id)'
PublicActivity::Activity.order('created_at DESC').where(condition, {type: object.class.to_s, id: object.id}).all PublicActivity::Activity.order('created_at DESC').where(condition, {type: self.class.to_s, id: self.id}).all
end end
private private
......
class PublicActivity::ActivitySerializer < ActiveModel::Serializer class PublicActivity::ActivitySerializer < ActiveModel::Serializer
attributes :id, :owner, :trackable, :recipient, :parameters, :created_at attributes :id, :owner, :trackable, :trackable_type, :recipient, :parameters, :created_at
end end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment