我有一个范围,用于查找 call_status 已打开且 unit_id 为 nil 的呼叫记录。
scope :unassigned_calls, where(:call_status => "open", :unit_id => nil).order("id ASC")
我最近设置了一个 has_many 关系,其中 unit_id 不再在调用模型上使用,而是在 call_unit 模型连接表上使用了一个名为 unit_ids 的字段。
如何将范围或 lambda 表示到它包含连接表中的 unit_ids 的位置?