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

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
854e9287641aae13c1045bc7df24bfbf?d=identicon&s=25 Jörg Battermann (joergbattermann)
on 2008-12-30 07: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'
activities.

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...!


Cheers,
-Joerg
80e4cb97cae5c8d745f72337d93fd8f2?d=identicon&s=25 MaD (Guest)
on 2008-12-30 09: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.