我编写了以下方法来结合模型及其子模型References
:Sections
def combined_references
ids = []
ids << self.id
self.children.each do |child|
ids << child.id
end
Reference.where("section_id = ?", ids)
end
但section.combined_references
返回以下错误:
Mysql2::Error: Operand should contain 1 column(s): SELECT `references`.* FROM `references` WHERE (section_id = 3,4)
似乎已经收集了正确的 id 值,我是否错误地构造了查询?