【发布时间】:2012-08-21 17:29:32
【问题描述】:
我有一个范围来查找 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 的位置?
【问题讨论】:
标签: ruby-on-rails ruby ruby-on-rails-3 join scope