【发布时间】:2011-12-22 22:59:39
【问题描述】:
假设我有:
class Post
has_many :tags, :through => :taggings
has_many :taggings
end
请注意,没有 :include。现在说我想在同一个查询中检索所有标签和标签。我怎么能这样做?
我正在寻找类似的东西:
taggings = post.taggings(:include => tags) # doesn't work
我可以使用 :include 进行自定义查询或向 Post 添加第三个关联,但感觉都不对。
【问题讨论】:
标签: ruby-on-rails activerecord associations has-many-through