Does it exist an OR operator in RoR ? I want or archieve something like this :
Model.where('cat_id' => 5 OR 'color' => 'grey').all
开发者_Python百科
I think I must use find_by_sql
nop ?
I believe this is the way:
Model.where('cat_id=? OR color=?', 5, 'grey')
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.
精彩评论