添加两个 ActiveRecord::Relation 对象 [英] adding two ActiveRecord::Relation objects
本文介绍了添加两个 ActiveRecord::Relation 对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何将两个关系加在一起?当我尝试 + 运算符时,它返回一个数组.但我需要它来返回一个关系.
How do you add two relations together? When I try the + operator it returns an array. But I need it to return a relation.
谢谢,迈克
推荐答案
尝试:
new_relation = relation.merge(another_relation)
这篇关于添加两个 ActiveRecord::Relation 对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文