我有两个型号,Deal和Contact。
我的联系人模型嵌入在交易模型中,一个交易中可以有多个联系人。
如何通过deal_ids获取联系人?
EX: deal_ids = [“a9s82sj”,“kswid”] 我想得到所有在deal_ids = deal_ids
内的联系人class Deal
include Mongoid::Document
include Mongoid::Pagination
include Mongoid::Timestamps
include Mongoid::IndexedFields
include Mongoid::Search
has_and_belongs_to_many :contacts
end
class Contact
include Mongoid::Document
include Mongoid::Pagination
include Mongoid::Timestamps
include Mongoid::IndexedFields
has_and_belongs_to_many :deals, inverse_of: :contacts, validate: false
end