我的代码中有一个语句:
RentalItem.last.maintenance_orders.where("status_id IS NOT 2").present?
在开发模式下工作良好,但在生产环境下不能在PostGreSQL中工作。问题是,语法是使代码工作的唯一方法,因为在我的陈述中,如果一个孩子 maintenance_order 有一个 status_id 属于 nil ,然后我想让 .present? 命令其他语法被忽略 无 Rails ActiveRecord find children where attribute is NOT a given value
maintenance_order
status_id
nil
.present?
无
关于如何改变这个语法有什么想法吗?
尝试:
RentalItem.last.maintenance_orders.where("status_id <> 2 or status_id is null").present?