Class Her::Model::Associations::HasManyAssociation
In: lib/her/model/associations/has_many_association.rb
Parent: Association

Methods

Public Class methods

Public Instance methods

Initialize a new object with a foreign key to the parent

@example

  class User
    include Her::Model
    has_many :comments
  end

  class Comment
    include Her::Model
  end

  user = User.find(1)
  new_comment = user.comments.build(:body => "Hello!")
  new_comment # => #<Comment user_id=1 body="Hello!">

TODO: This only merges the id of the parents, handle the case

      where this is more deeply nested

Create a new object, save it and add it to the associated collection

@example

  class User
    include Her::Model
    has_many :comments
  end

  class Comment
    include Her::Model
  end

  user = User.find(1)
  user.comments.create(:body => "Hello!")
  user.comments # => [#<Comment id=2 user_id=1 body="Hello!">]

@private

[Validate]