模块:Mongoid::Association::Macros::ClassMethods
- 定义于:
- lib/mongoid/association/macros.rb
Overview
用于关联的类方法。
实例方法摘要折叠
-
# belongs_to (name, options = {}, &block) ⇒ 对象
将引用的关联从子文档添加到另一个数据库或集合中的文档。
-
# embedded_in (name, options = {}, &block) ⇒ 对象
将关联添加回父文档。
-
# embeds_many (name, options = {}, &block) ⇒ 对象
添加父文档与其子文档的关联。
-
# embeds_one (name, options = {}, &block) ⇒ 对象
添加父文档与其子文档的关联。
-
# has_and_belongs_to_many (name, options = {}, &block) ⇒ 对象
在此文档的许多部分与另一个文档的许多部分之间添加引用的多对多关联。
-
# has_many (name, options = {}, &block) ⇒ 对象
将引用的关联从父文档添加到另一个数据库或集合中的许多文档。
-
# has_one (name, options = {}, &block) ⇒ 对象
将引用的关联从子文档添加到另一个数据库或集合中的文档。
实例方法详细信息
# belongs_to (name, options = {}, &block) ⇒对象
将引用的关联从子文档添加到另一个数据库或集合中的文档。
148 149 150 |
# File 'lib/mongoid/association/macros.rb', line 148 def belongs_to(名称, = {}, 和块) define_association!(__method__, 名称, , 和块) end |
# embedded_in (name, options = {}, &block) ⇒对象
将关联添加回父文档。 要设立子文档对父文档的引用,必须使用该宏。 如果子对象未定义此关联,则在子对象上调用持久性方法将导致保存失败。
80 81 82 |
# File 'lib/mongoid/association/macros.rb', line 80 def (名称, = {}, 和块) define_association!(__method__, 名称, , 和块) end |
# embeds_many (name, options = {}, &block) ⇒对象
添加父文档与其子文档的关联。 关联的名称必须是子类名称的复数形式。
103 104 105 |
# File 'lib/mongoid/association/macros.rb', line 103 def (名称, = {}, 和块) define_association!(__method__, 名称, , 和块) end |
# embeds_one (name, options = {}, &block) ⇒对象
添加父文档与其子文档的关联。 关联名称必须是子类名称的单数形式。
126 127 128 |
# File 'lib/mongoid/association/macros.rb', line 126 def (名称, = {}, 和块) define_association!(__method__, 名称, , 和块) end |
# has_and_belongs_to_many (name, options = {}, &block) ⇒对象
在此文档的许多部分与另一个文档的许多部分之间添加引用的多对多关联。
194 195 196 |
# File 'lib/mongoid/association/macros.rb', line 194 def has_and_belongs_to_many(名称, = {}, 和块) define_association!(__method__, 名称, , 和块) end |
# has_many (name, options = {}, &block) ⇒对象
将引用的关联从父文档添加到另一个数据库或集合中的许多文档。
172 173 174 |
# File 'lib/mongoid/association/macros.rb', line 172 def has_many(名称, = {}, 和块) define_association!(__method__, 名称, , 和块) end |
# has_one (name, options = {}, &block) ⇒对象
将引用的关联从子文档添加到另一个数据库或集合中的文档。
216 217 218 |
# File 'lib/mongoid/association/macros.rb', line 216 def has_one(名称, = {}, 和块) define_association!(__method__, 名称, , 和块) end |