Ruby on rails rails仅在模型实例变量中获取真正的布尔对象

Ruby on rails rails仅在模型实例变量中获取真正的布尔对象,ruby-on-rails,database,model,boolean,Ruby On Rails,Database,Model,Boolean,我目前正在获取模型中的所有注释 @notes_list = current_user.notes.order(:title).group_by { |note| note.title[0] } 后来我在notes表中添加了一列,该列是已知的布尔列 现在我只想分别获取真值列和假值列,如下所示 @notes_true_list = blah.... @notes_false_list = blah.... 有人能帮我吗?试试下面的代码 @notes_true_list = current_use

我目前正在获取模型中的所有注释

@notes_list = current_user.notes.order(:title).group_by { |note| note.title[0] }
后来我在notes表中添加了一列,该列是已知的布尔列

现在我只想分别获取真值列和假值列,如下所示

@notes_true_list = blah....
@notes_false_list = blah....
有人能帮我吗?

试试下面的代码

@notes_true_list = current_user.notes.where(known: true).order(:title).group_by { |note| note.title[0] }

@notes_false_list = current_user.notes.where(known: false).order(:title).group_by { |note| note.title[0] }