Method: Parse::Associations::HasOne.has_one

Defined in:
lib/parse/model/associations/has_one.rb

.has_one(key, scope = nil, opts = {}) ⇒ Parse::Object

Creates a one-to-one association with another Parse model.

Parameters:

  • key (Symbol)

    The singularized version of the foreign class and the name of the foreign column in the foreign Parse table where the pointer is stored.

  • scope (Proc) (defaults to: nil)

    A proc that can customize the query by applying additional constraints when fetching the associated record. Works similarly as ActiveModel associations described in section Customizing the Query

Options Hash (opts):

  • :field (Symbol)

    override the name of the remote column where the pointer is stored. By default this is inferred as the columnized of the key parameter.

  • :as (Symbol)

    override the inferred Parse::Object subclass. By default this is inferred as the singularized camel case version of the key parameter. This option allows you to override the Parse model used to perform the query for the association, while allowing you to have a different accessor name.

  • scope_only (Boolean)

    Setting this option to true, makes the association fetch based only on the scope provided and does not use the local instance object as a foreign pointer in the query. This allows for cases where another property of the local class, is needed to match the resulting records in the association.

Returns:

  • (Parse::Object)

    a Parse::Object subclass when using the accessor when fetching the association.

See Also:



# File 'lib/parse/model/associations/has_one.rb', line 83