【发布时间】:2017-02-25 11:36:50
【问题描述】:
我有一个索引页,我想在其中显示特色板和标准板。特色版块有 has_one 付款,标准版块没有。
class Payment < ApplicationRecord
belongs_to :board
end
class Board < ApplicationRecord
has_one :payment
end
所以我可以通过加入付款并因此删除标准板来识别特色板。
Board.joins(:payment).where(category: category, confirmed: true)
现在我想通过以下方式获得标准列表:
Board.where(category: category, confirmed: true)
但这都会返回特色板和标准板。
我正在寻找一种获得标准列表(没有付款的板)的方法,但我不知道如何做到这一点。
【问题讨论】:
-
查看下面的编辑答案
-
我觉得特意寻求我的帮助然后忽略我的回答是很不礼貌的......
-
@TheCha͢mp 你的回答让我朝着正确的方向前进
标签: ruby-on-rails join activerecord