我知道includes和extract_associated方法。这里使用的extract_associated在Rails文档中只返回用户记录- account.memberships.extract_associated(:user)
# => Returns collectionof User records 我希望返回成员记录,用户记录在相同的数组中</em
后续问题:Want to find records with no associated records in Rails 我想知道如何才能将所有非孤立记录作为AssociationRelation而不是数组返回在尝试从rails 6 .missing记录中减去表的总记录时,结果是正确的,但它是以数组的形式出现的。下面是一个控制台示例: p = ProductRe
我在我的Rails项目中使用Elastic Search。我正在使用elasticsearch-model gem进行实时全文搜索。假设模型A属于模型B。如果我在模型A上进行搜索,根据我的搜索参数,我会得到A的10条记录。A.search(x) => Gives 10 records which includes all attributes of A.ElasticSearch中加载关联?另
在我的显示页面中,我执行了一个Comment.all,然后显示每个评论。<% end %>
这很好,但是activerecord会为我的每条评论转换一个SELECT * FROM users WHERE USER.id = commentId查询。这有点可笑,特别是在一个有数百条评论的页面上。(这是数百个单独的数据库命中!)当我做Comment.a