Joins, Joins, Joins! Or Not?

Good morning,

I have a quick joins-related question:

I have a a list of followings (User following another user’s activity)
which basically have these followed users’ ids under ‘followable_id’.
now what I want to do and finally have is to take these followed users
and check what activities they have. each activity has a .user_id. how
would I do this?

So Basically

A User is following X other Users (polymorphic intermediate model… a
User can also follow discussions etc). Each of those users has a set
of activities.

What I basically want in a ‘speedy’ way is to get all followed users’

I kinda have a problem with the polymorphism of the Follow model, as
apparently I cannot put a has_many relationship into the user model
which would allow me a condition (followable_type = “User”), class
(User) and source (:followable)…

I am kinda lost… been wrangling with join conditions all night :-/

Any ideas / suggestions? Would be highly, highly appreciated…!


i’m not sure if i understand correctly what you are doing. could you
post your models and relations so far?

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs