Does Rails 4 have support for OR queries

前端 未结 7 1922
暗喜
暗喜 2020-12-08 13:14

So in Rails 4 the long desired feature to use not queries has been added.

Article.where.not(title: \'Rails 3\')

Has similar su

7条回答
  •  借酒劲吻你
    2020-12-08 13:35

    You can use Squeel for more complex queries:

    Article.where{(title == 'Rails 3') | (title == 'Rails 4')}
    

    This results in the following SQL query:

    SELECT `articles`.* FROM `articles` WHERE ((`articles`.`title` = 'Rails 3' OR `articles`.`title` = 'Rails 4'))
    

提交回复
热议问题