ActiveRecord where field = ? array of possible values

后端 未结 6 1139
無奈伤痛
無奈伤痛 2020-12-13 07:47

I want to do

Model.where(\'id = ?\', [array of values])

How do I accomplish this look up without chaining OR statements together?

6条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-13 08:49

    From the ActiveRecord Query Interface guide

    If you want to find records using the IN expression you can pass an array to the conditions hash:

    Client.where(orders_count: [1,3,5])
    

提交回复
热议问题