ActiveRecord:使用" OR"加入的哈希查询模型而不是" AND"

时间:2014-09-04 18:29:00

标签: ruby-on-rails ruby ruby-on-rails-4

说我有像这样的哈希

attributes = {"brown" => true, "black" => false, "rocky" => true, "pebbles" => false, "beige" => true, "white" => false, "red" => true, "pink" => "true" }

我有一个模型Beach,我想查询哈希

中的属性
Beach.where(attributes)

我相信这会将哈希属性与AND子句brown is true AND black is false AND rocky = true.

结合起来

我需要使用OR条件brown is true OR black is false OR rocky is true加入哈希属性。有任何想法吗?谢谢!

0 个答案:

没有答案