Forum: Ruby on Rails Joins, Joins, Joins! Or Not?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Jörg B. (Guest)
on 2008-12-30 08:07
(Received via mailing list)
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...!

MaD (Guest)
on 2008-12-30 10:32
(Received via mailing list)
i'm not sure if i understand correctly what you are doing. could you
post your models and relations so far?
This topic is locked and can not be replied to.