我的代码中有一条声明:
retention_time
在开发模式下工作正常,但在生产中的PostGreSQL中没有。麻烦的是,语法是使代码工作的唯一方法,因为在我的陈述中,如果孩子RentalItem.last.maintenance_orders.where("status_id IS NOT 2").present?
的{{1}}为maintenance_order
,那么我希望它可以在status_id
命令。其他语法忽略了nil
。在此处查看此问题:Rails ActiveRecord find children where attribute is NOT a given value
有关如何更改此语法的任何想法?
答案 0 :(得分:0)
尝试:
RentalItem.last.maintenance_orders.where("status_id <> 2 or status_id is null").present?