On Apr 25, 2:41 am, Juan Pablo Avello <xua...@gmail.com> wrote: > Or, if phone nos. are different: > > phones = [['31', '32221'0412'], ['32','422020202']].map{|q| > "phones.area_code = #{q[0]} and phones.number = #{q[1]}"}.join(' or ') > Lawyer.includes(:phones).where(phones)
That one could lead to injection, I think. However, something like this would work: phones = [['31', '322210412'], ['32','422020202']] query = phones.map{|q| "phones.area_code = ? and phones.number = ?"}.join(' or ') Lawyer.includes(:phones).where(query, phones.flatten) This seems to be the best solution so far. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.