【发布时间】:2015-06-26 19:21:26
【问题描述】:
我在模型中有一个自关联
belongs_to :parent, class_name: "Person"
has_many :children, foreign_key: :parent_id, class_name: "Person"
通过where(parent_id: nil)获取父母
如何获得所有没有孩子的人物模型作为范围?
【问题讨论】:
标签: ruby-on-rails ruby-on-rails-4 activerecord scope model-associations