我对轨道相当陌生,我遇到了一些模型关系问题。关系模型
我有这些表
+--------------+-----------------+------+
| Artists | Artist Features | Tags |
+--------------+-----------------+------+
| ID | ID | ID |
| Name | artist_id | name |
| Address | price | |
| Country | tag_id | |
| Email | | |
+--------------+-----------------+------+
我有艺术家和艺术家之间的关系特点 artists
has_many
artist_features
和artist_features
has_many
标签。我想,一个查询得到基于上述结构中的所有艺术家,功能和标签,artist_id
和tag_id
我用下面得到artists
和相应的artist_features
但想也得到了太多的标签基于该tag_id
@Artists = Artist.all.artist_features
如果艺术家功能'has_many'标签,那么您应该在'tags'表上有'artist_feature_id'列,而不是'artist_features'表上的'tag_id'列。 –