Ruby on rails 如何在Rails查询中找到nil的对立面
愉快地使用Ruby on rails 如何在Rails查询中找到nil的对立面,ruby-on-rails,activerecord,mongoid,Ruby On Rails,Activerecord,Mongoid,愉快地使用Mongoid和ActiveRecord如下: Task.where(project_id: params[:project_id], archived_at: nil) # find me the tasks for project_id that haven't been archived 但是,用什么简单的方式来表达相反的意思呢 # find me the tasks for project_id that have been archived # i.e. where arc
Mongoid
和ActiveRecord
如下:
Task.where(project_id: params[:project_id], archived_at: nil)
# find me the tasks for project_id that haven't been archived
但是,用什么简单的方式来表达相反的意思呢
# find me the tasks for project_id that have been archived
# i.e. where archived_at is not nil
无法找出或找出第一行代码的倒数。
我想这应该很简单:)我想你应该用这个:
:archived_at.ne => nil
请看这里: