Class Her::Model::Associations::BelongsToAssociation
In: lib/her/model/associations/belongs_to_association.rb
Parent: Association

Methods

Public Class methods

Public Instance methods

Initialize a new object

@example

  class User
    include Her::Model
    belongs_to :organization
  end

  class Organization
    include Her::Model
  end

  user = User.find(1)
  new_organization = user.organization.build(:name => "Foo Inc.")
  new_organization # => #<Organization name="Foo Inc.">

Create a new object, save it and associate it to the parent

@example

  class User
    include Her::Model
    belongs_to :organization
  end

  class Organization
    include Her::Model
  end

  user = User.find(1)
  user.organization.create(:name => "Foo Inc.")
  user.organization # => #<Organization id=2 name="Foo Inc.">

@private

[Validate]