How to express a NOT IN query with ActiveRecord/Rails?
Solution 1:
Rails 4+:
Article.where.not(title: ['Rails 3', 'Rails 5'])
Rails 3:
Topic.where('id NOT IN (?)', Array.wrap(actions))
Where actions
is an array with: [1,2,3,4,5]
Solution 2:
FYI, In Rails 4, you can use not
syntax:
Article.where.not(title: ['Rails 3', 'Rails 5'])