适用于SQLite但不适用于PostGreSQL ...属性不是1

时间:2016-07-22 02:40:22

标签: ruby-on-rails postgresql sqlite ruby-on-rails-4 rails-activerecord

我的代码中有一条声明:

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

有关如何更改此语法的任何想法?

1 个答案:

答案 0 :(得分:0)

尝试:

RentalItem.last.maintenance_orders.where("status_id <> 2 or status_id is null").present?