Forum: Ruby on Rails Need :through to work as has many rather than HABTM.

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.
92dafea96df3ff949b426b235a19ae0e?d=identicon&s=25 ChrisT (Guest)
on 2006-03-21 20:18
(Received via mailing list)
I've a horrible feeling I'm missing something here, but I'd like to have
something like :through to model a has_many relationship rather than a
HABTM relationship (and I don't think it does).

The is the model I have (simplified):

Users have many Models (and Models belong to Users)
Models have many Pieces (and Pieces belong to Models)

In (badly drawn) graphical form:
            _________               _______________
          /                                 /
Users/--------------Models/----------------------Pieces
         \__________             \________________

In a perfect world you would be able to use something like :through to
get user.pieces...
...but I know we don't live in one of those. So, is there a neat way of
doing this?

Thanks in advance

Chris T
925c5035ff3e0005e0604c0cd869b5cf?d=identicon&s=25 Chris T (Guest)
on 2006-03-21 20:36
ChrisT wrote:
> I've a horrible feeling I'm missing something here, but I'd like to have
> something like :through to model a has_many relationship rather than a
> HABTM relationship (and I don't think it does).
>
Never mind. Solved this through defining an instance method in the users
class. Guess I was too eager to uses Edge Rails new bells&whistles
forgot about the basics.
CT
This topic is locked and can not be replied to.