user2968505
user2968505

Reputation: 445

Ruby on Rails, using activerecord to get all records that have a specified field containing a string in my array

So i know i can do something like this Model.Where('field LIKE ?','%mystring%') to get all records containing my string inside my specified field.

But is there to make it check through an array of strings rather than a single string ?

Upvotes: 0

Views: 162

Answers (1)

Yaro
Yaro

Reputation: 568

This should do in PostgreSQL:

Model.where("field ILIKE any (array[?])", ["%mystring1%", "%mystring2%"])

Upvotes: 1

Related Questions