标签: ruby-on-rails-4 activerecord
给定以下简单关联和selected_company,我的查询是否正确编写以获取所选公司中的所有文档?
results
感谢您的反馈
答案 0 :(得分:0)
只需2个小修补程序,关联名称应为小写...并且where应包含查询字符串:
documents_in_selected_company = Document.joins(:user).joins(:user => :company).where("companies.id = ?", company.id)