RoR:搜索逻辑:如何进行左连接,而不是默认的左内连接?
我正在根据引用另一个表的字段进行排序(并根据另一个表的“名称”字段进行排序)。问题是,当我的第一组对象中有一些条目没有对另一个条目的引用时,该条目将被排除在排序之外。
简而言之,我有一个列是对另一个表的引用(并对该表中的列进行排序),但我也想包含空引用。
I'm doing sorting based on a field that references another table (and sorting on that other table's 'name' field). The issue is that when my first set of objects has some entries that don't have a reference to the other, that entry is excluded from the sorting.
So.. in short, I have a column that is a reference to another table (and sorting over a column in that table), but I also want to include null references.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不是 100% 确定我理解你的问题,但是例如,当你编写一个named_scope时,你可以传递这样的选项:
另一个例子:
I am not 100% sure I understand your question, but for example, when you write a named_scope you can pass options like this:
another example: