我有一个模型Person
和一个数据表PersonCode
。现在在我的控制器中,我想搜索多个代码。什么是正确的方法呢?
我尝试在Person
def self.code_filter(codes)
joins(:PersonCode)
codes.each do |code|
where("rank > 1 AND person_code.code LIKE '%" + code +"%'")
end
但是,当我在控制器中调用此类方法时,请说[' Z'' Q']
Person
.code_filter(my_array)
.another_query_method(some_value)
我收到以下错误消息:"未定义的方法`another_query_method' for [" Z"," Q"]:Array"
我知道为什么这不起作用但是如何使用这些SQL语句进行正确连接的查询?
答案 0 :(得分:0)