Quantcast
Channel: Rails public_activity feed with polymorphic following - Stack Overflow
Viewing all articles
Browse latest Browse all 3

Answer by Loren for Rails public_activity feed with polymorphic following

$
0
0

For users:

@activities = PublicActivity::Activity.where(owner_id: current_user.follows_by_type('User'), owner_type: 'User').order("created_at desc")

For bands:

@activities = PublicActivity::Activity.where(owner_id: current_user.follows_by_type('Band'), owner_type: 'Band').order("created_at desc")

For a mixture:

@activities = PublicActivity::Activity.where("(owner_id IN (?) AND owner_type = 'User') or (owner_id IN (?) AND owner_type = 'Band')", current_user.follows_by_type('User'), current_user.follows_by_type('Band')).order("created_at desc")

Viewing all articles
Browse latest Browse all 3

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>