has_many的嵌套查询:通过rails

时间:2016-02-01 11:18:19

标签: ruby-on-rails activerecord

模型的关联是

class Campaign
  has_many :views_logs
  has_many :users, through: :views_logs
end

我想只获得那些在特定日期创建views_logs的广告系列用户。

注意:views_logs的created_at查询不适用于用户创建

1 个答案:

答案 0 :(得分:1)

JOIN

加入像这样的用户将在您的views_logs上执行SQL JOIN,然后在用户上执行SQL WHERE,这允许您在C:\>sigcheck.exe -vt "C:\Program Files\Google\Chrome\Application\chrome.exe" Sigcheck v2.42 - File version and signature viewer Copyright (C) 2004-2016 Mark Russinovich Sysinternals - www.sysinternals.com c:\program files\google\chrome\application\chrome.exe: Verified: Signed Signing date: 5:53 AM 1/29/2016 Publisher: Google Inc Company: Google Inc. Description: Google Chrome Product: Google Chrome Prod version: 50.0.2633.3 File version: 50.0.2633.3 MachineType: 32-bit VT detection: 1/55 VT link: https://www.virustotal.com/file/f65dda151e7e52baa5619a08 1d687479a9d65d2f3d67f2481d6c60b85de11080/analysis/ 条件下使用view_logs列。