# What is the difference build and new?

**URL:** <https://www.ruby-forum.com/t/what-is-the-difference-build-and-new/187446>\
**Category:** Ruby\
**Created:** [April 23, 2010, 9:34am UTC](https://www.ruby-forum.com/t/what-is-the-difference-build-and-new/187446 "2010-04-23T09:34:38Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![manoj](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/d9b06d/32.png) [@manoj](https://www.ruby-forum.com/u/manoj)\
**Post date:** [April 23, 2010, 9:34am UTC](https://www.ruby-forum.com/t/what-is-the-difference-build-and-new/187446/1 "2010-04-23T09:34:38Z")

</div>

What is the difference between

parent.children \<\< child.new

and

parent.children.build(params[:child])

---

<div class="post-metadata">

**Author:** ![manoj](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/d9b06d/32.png) [@manoj](https://www.ruby-forum.com/u/manoj)\
**Post date:** [April 23, 2010, 10:17am UTC](https://www.ruby-forum.com/t/what-is-the-difference-build-and-new/187446/2 "2010-04-23T10:17:32Z")

</div>

2010/4/23 Manoj K. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> What is the difference between
> 
> parent.children \<\< child.new
> 
> and
> 
> parent.children.build(params[:child])

What is the question? Seriously you do not provide any information  
about context or what code you are presenting. How do you expect us  
to answer such a question?

Regards

robert

---

<div class="post-metadata">

**Author:** ![manoj](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/d9b06d/32.png) [@manoj](https://www.ruby-forum.com/u/manoj)\
**Post date:** [April 23, 2010, 4:38pm UTC](https://www.ruby-forum.com/t/what-is-the-difference-build-and-new/187446/3 "2010-04-23T16:38:05Z")

</div>

Robert K. wrote:

> 2010/4/23 Manoj K. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):
> 
> > What is the difference between
> > 
> > parent.children \<\< child.new
> > 
> > and
> > 
> > parent.children.build(params[:child])
> 
> What is the question? Seriously you do not provide any information  
> about context or what code you are presenting. How do you expect us  
> to answer such a question?

At a guess, it’s an ActiveRecord question.

ActiveRecord is a component of Rails. If you have a question on Rails,  
please use a Rails mailing list. I’m sure it’s not intentional, but it’s  
rather rude to post a question about one subject (Rails) on a mailing  
list devoted to another (Ruby).

Rails is not Ruby - it’s an application framework which just happens to  
be written _in_ Ruby.

---

<div class="post-metadata">

**Author:** ![manoj](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/d9b06d/32.png) [@manoj](https://www.ruby-forum.com/u/manoj)\
**Post date:** [April 26, 2010, 6:10am UTC](https://www.ruby-forum.com/t/what-is-the-difference-build-and-new/187446/4 "2010-04-26T06:10:32Z")

</div>

Thanks Luis…

---

<div class="post-metadata">

**Author:** ![manoj](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/d9b06d/32.png) [@manoj](https://www.ruby-forum.com/u/manoj)\
**Post date:** [April 23, 2010, 7:00pm UTC](https://www.ruby-forum.com/t/what-is-the-difference-build-and-new/187446/5 "2010-04-23T19:00:53Z")

</div>

On Apr 23, 4:34 am, Manoj K. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> What is the difference between
> 
> parent.children \<\< child.new
> 
> and
> 
> parent.children.build(params[:child])

> **[ActiveRecord::Associations::ClassMethods](https://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html)**
>
> Associations are a set of macro-like class methods for tying objects together through foreign keys.

Under has\_many examples, build is used to automatically fill up the  
relationship data. The documentation is your friend, spend some time  
reading it.

Now that I’ve google that for you, another useful link:

> **[Community](https://rubyonrails.org/community)**
>
> A web-app framework that includes everything needed to create database-backed web applications according to the Model-View-Controller (MVC) pattern.

Post your Ruby on Rails related questions there in the Rails mailing  
lists, not here as there are better chances you don’t get any answer  
at all since this list is mainly Ruby.
