mazikwyry
mazikwyry

Reputation: 197

OR condition in where method ActiveRecord

How can I achieve something like this in Rails (if there is a way) with hash parameters without writing a where string:

Model.where(**:launched => nil or false**, :verify => false, :pools => {:status => 'later'})

Upvotes: 1

Views: 98

Answers (1)

Peter de Ridder
Peter de Ridder

Reputation: 2399

Model.where(:launched => [nil, false], :verify => false, :pools => {:status => 'later'})

Now you will query for all objects where :launched is nil or false.

P.s. Ditch the hash rockets and use the cleaner Ruby 1.9+ syntax, unless of course you want to stick with ruby 1.8.7 or earlier. For example: Model.where(launched: [nil, false])

Upvotes: 6

Related Questions