Module: Parse::Associations::BelongsTo
- Included in:
- Object
- Defined in:
- lib/parse/model/associations/belongs_to.rb
Overview
This association creates a one-to-one association with another Parse model. BelongsTo relation is the simplies association in which the local Parse table constains a column that has a Parse::Pointer to a foreign table record.
This association says that this class contains a foreign pointer column which references a different class. Utilizing the `belongs_to` method in defining a property in a Parse::Object subclass sets up an association between the local table and a foreign table. Specifying the `belongs_to` in the class, tells the framework that the Parse table contains a local column in its schema that has a reference to a record in a foreign table. The argument to `belongs_to` should be the singularized version of the foreign Parse::Object class. you should specify the foreign table as the snake_case singularized version of the foreign table class.
Note that the reverse relationship on the foreign class is not generated automatically. You can use a `has_one` on the foreign model to create it.
Class Attribute Summary collapse
- .references ⇒ Hash
A hash mapping of all belongs_to associations for this model.
Class Method Summary collapse
- .belongs_to(key, opts = {}) ⇒ Parse::Object
Creates a one-to-one association with another Parse model.
Instance Method Summary collapse
- #key? ⇒ Boolean
A dynamically generated method based on the value of `key` passed to the belongs_to method, which returns true if this instance has a pointer for this field.
Class Attribute Details
.references ⇒ Hash
A hash mapping of all belongs_to associations for this model.
# File 'lib/parse/model/associations/belongs_to.rb', line 55
|
Class Method Details
.belongs_to(key, opts = {}) ⇒ Parse::Object
Creates a one-to-one association with another Parse model.
# File 'lib/parse/model/associations/belongs_to.rb', line 59
|
Instance Method Details
#key? ⇒ Boolean
A dynamically generated method based on the value of `key` passed to the belongs_to method, which returns true if this instance has a pointer for this field.
# File 'lib/parse/model/associations/belongs_to.rb', line 91
|