Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我将如何组合以下两个 AR 对象(从两个单独的查询返回):
user1 = User.first
和
user2 = User.last
进入适当的 AREL 对象,例如:
@users = user1, user2
我认为这没问题:@users = [user1, user2]
@users = [user1, user2]
尝试:
@users = user1 + user2
我知道这适用于从数据库中检索到的对象数组,但不确定单个对象。
否则,可能会像下面这样工作:
@users = [] << user1 << user2