【发布时间】:2016-03-30 01:22:57
【问题描述】:
我有以下型号:
class PropertyType < ApplicationRecord
has_one :parent, :class_name => "PropertyType"
has_and_belongs_to_many :properties
end
它可以有它自己的类类型的父类。但是,以下查询似乎都不起作用:
PropertyType.where("property_type_id IS NULL")
PropertyType.where(parent: nil)
我在这里错过了什么?
【问题讨论】:
-
该模型的数据库架构是什么样的。
-
是的,没有上下文和架构很难说。具体来说,什么不起作用?您是否收到错误或错误/空结果?
标签: ruby-on-rails ruby-on-rails-4 activerecord ruby-on-rails-5