Complicted ActiveRecord Association. Going through a 4th table
Posted
by Dex
on Stack Overflow
See other posts from Stack Overflow
or by Dex
Published on 2010-04-22T00:29:31Z
Indexed on
2010/04/22
0:33 UTC
Read the original article
Hit count: 340
I have kind of a complicated case and am wondering how this would work in rails:
I want to categories the genres of some singers. Singers can belong to more than one genres, and users can assign tags to each genre
For example: singers <-- singers_genres --> genres <-- genres_tags --> tags
SQL would look something like: SELECT * FROM singers S INNER JOIN singers_genres SG ON S.id=SG.singer_id INNER JOIN genres G ON G.id = SG.genre_id LEFT OUTER JOIN genre_tags GT ON G.id = GT.genre_id INNER JOIN tags T ON GT.tag_id = T.id
© Stack Overflow or respective owner