从DB中选择没有值

And*_*dov 0 ruby database postgresql ruby-on-rails

我有自己的rails应用程序,我需要指定我想从DB(pg)获得什么.普通的,我们这样做:@posts = Post.all我将在Post Table中获得所有帖子.

在帖子表中,我有一个类别,作为布尔值:(照片,视频等),当我想只选择帖子对照片类别的响应时,我们这样做: @posts = Post.where(photo: true)

但我需要的是选择所有帖子,例如视频.它必须看起来像这样:@posts = Post.all.without(video:true).如何实现?

更新

有没有可能阻止几个值?我的意思是这样的Post.where.not(id: 1 && 2).我真的不知道它的样子.我需要的是选择没有ID为1和2的帖子的所有帖子.

Urs*_*sus 5

尝试

@posts = Post.where.not(video: true)
Run Code Online (Sandbox Code Playgroud)