Search code examples
rubyruby-on-rails-3.2arelsqueel

Squeel iterating through an array with OR in Where block


I have the following query in Squeel:

languages = where{ (name == 'English') | 
 (name == 'Spanish')  | 
 (name == 'German')  | 
 (name == 'French')  | 
 ...
}

Which works fine but I was wodering if there was a way to iterate through an array with those values to make it easier to add and remove languages. Say I created and array:

languages_array = %w[ English Spanish French ... ]

Is there any way to iterate with Squeel in a Where block?

I've tried everything I can think of without success.

Thanks.


Solution

  • I think this should work

    where{name.in(languages_array)}