http://stackoverflow.com/questions/3676305/mongoid-uniqueness-validation-many-to-many-relation
class Person
include Mongoid::Document
field :name
references_many :preferences, :stored_as => :array, :inverse_of => :people
end
class Preference
include Mongoid::Document
field :name
references_many :people, :stored_as => :array, :inverse_of => :preferences
end
ps1 = Person.create(:name => 'John Doe')
pf1 = Preference.create(:name => 'Preference A')
pf2 = Preference.create(:name => 'Preference B')
ps1.preferences << pf1
ps1.preferences << pf2
ps1.save
pf1.people.each {|ps| puts ps.name }
ps1.preferences.each {|pf| puts pf.name }
- 大小: 4 KB
分享到:
相关推荐
解决ERR_TOO_MANY_REDIRECTS
AIX关于Weblogic的报错_Too_many_open_files_的处理
many2many_radio单选按钮
针对one2many中many部分的记录,自定义删除条件控制,不符合条件的记录行后面将不显示删除图标。
pep三年级英语下Unit6_how_many__B_Let's_learn(1).ppt
讲解hibernate的ont_to_many关系配置,希望对你有点用处,谢谢
小学英语外研版三年级上册Unit1_How_many_课件PPT课件.pptx
SPIN PROTOCOL FOR ONE TO MANY FOR WIRELESS SENSOR NETWORK
Many_Birds,_One_Stone__Exploiting_a_Single_SQLite_Vulnerability_Across_Multiple_Software 金融安全 安全研究 安全实践 工控安全 自动化
test_manytest_manytest_many.csv
activemodel-associations, 用于普通 ruby 对象的has_many和belongs_to宏 ActiveModel::Associations 用于普通 ruby 对象的has_many 和 belongs_to 宏。安装将此行添加到你的应用程序的Gemfile中:gem 'activemodel-
「系统安全」Many_Birds,_One_Stone__Exploiting_a_Single_SQLite_Vulnerability_Across_Multiple_Software - 自动化 零信任 法律法规 WEB应用防火墙 安全资讯 业务安全
Hibernate 集合映射:基于HashMap多对多映射 代码,代码出处:http://www.itneng.com/thread-3713-1-1.html
小学英语外研版三年级上册Unit1_How_many_课件PPT学习教案.pptx
资源分类:Python库 所属语言:Python 资源全名:many_versioned_wheel-0.2.0-py2.py3-none-any.whl 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059
三年级上册英语一课一练-Module 5 Unit 1 How many_外研版(三起)扫描版.doc
本文主要介绍了如何解决安装wordpress时出现ERR_TOO_MANY_REDIRECTS重定向次数过多导致无法安装的问题
hibernate many-to-many级联保存,级联更新,级联删除
NULL 博文链接:https://diaochenlong2.iteye.com/blog/1732676