【发布时间】:2015-10-28 10:07:41
【问题描述】:
我有两个模型,ParentProfile 和 RoomParentAssignment:
class ParentProfile < ActiveRecord::Base
has_many :room_parent_assignments
和
class RoomParentAssignment < ActiveRecord::Base
belongs_to :room_parent_profile, class_name: 'ParentProfile', foreign_key: 'parent_profile_id'
我想检索所有有没有room_parent_assignments的ParentProfile记录。我正在寻找类似以下语句的内容(不用说,是无效的):
@non_room_parents = ParentProfile.where(!room_parent_assignments.present?)
我该怎么做?
【问题讨论】:
标签: ruby-on-rails activerecord