Reputation: 5145
Does it exist an OR operator in RoR ? I want or archieve something like this :
Model.where('cat_id' => 5 OR 'color' => 'grey').all
I think I must use find_by_sql
nop ?
Upvotes: 2
Views: 1206
Reputation:
You might consider looking at the MetaWhere gem. It supports compound conditions with syntax like this:
Article.where(:title.matches % 'Hello%' | :title.matches % 'Goodbye%')
It has a lot more to it than just that but it is a really great gem to augment Arel.
Upvotes: 3
Reputation: 4176
I believe this is the way:
Model.where('cat_id=? OR color=?', 5, 'grey')
Upvotes: 6