Ecto.Model.build/2

Parsed documentation:
View on GitHub
Builds a structs from the given `assoc` in `model`.

## Examples

If the relationship is a `has_one` or `has_many` and
the key is set in the given model, the key will automatically
be set in the built association:

    iex> post = Repo.get(Post, 13)
    %Post{id: 13}
    iex> build(post, :comment)
    %Comment{id: nil, post_id: 13}

Note though it doesn't happen with belongs to cases, as the
key is often the primary key and such is usually generated
dynamically:

    iex> comment = Repo.get(Post, 13)
    %Comment{id: 13, post_id: 25}
    iex> build(comment, :post)
    %Post{id: nil}
Suggestions:
Please help! Open an issue on GitHub if this assessment is incorrect.