没有任何数据可供显示
开源项目社区 | 当前位置 : |
|
www.trustie.net/open_source_projects | 主页 > 开源项目社区 > rich-join-association |
rich-join-association
|
0 | 0 | 0 |
贡献者 | 讨论 | 代码提交 |
The goal of rich-join-association is to make it simpler to make use of has_many :through associations in which the join table has a single additional attribute.
(Example adapted from http://blog.hasmanythrough.com/articles/2006/04/20/many-to-many-dance-off)
So if you had Dancers, Movies, and Appearances and each Appearance had an attribute character_name, rather than saying:
dan = Dancer.new
cameo = Appearance.new
cameo.dancer = dan
cameo.movie = Movie.find_by_name 'Served'
cameo.character_name = 'Joe the Dancemaster'
dan.appearances << cameo
One would simply enter
dan = Dancer.new
s.cameos['Served'] = 'Joe the Dancemaster'
Currently, you can only use one join attribute per pair of classes joined, but if an Appearance also joined a Dancer to a Song with an attribute quality_of_performance, that would work as well.