# No build! on association?

**URL:** <https://www.ruby-forum.com/t/no-build-on-association/113936>\
**Category:** Rails\
**Created:** [September 6, 2007, 11:36am UTC](https://www.ruby-forum.com/t/no-build-on-association/113936 "2007-09-06T11:36:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tarsoly\_AndrSSSSs](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/57b2e6/32.png) [@Tarsoly\_AndrSSSSs](https://www.ruby-forum.com/u/Tarsoly_AndrSSSSs)\
**Post date:** [September 6, 2007, 11:36am UTC](https://www.ruby-forum.com/t/no-build-on-association/113936/1 "2007-09-06T11:36:25Z")

</div>

Hi guys,

it seems like I missed some trivial stuff going on in edge rails. Can  
you point me in the right direction about what happened to the build!  
method?

Simple scenario:

class User \<\< AR  
has\_many :posts  
end

class Post  
belongs\_to :user  
end

console:

> > u = User.find(1)  
> > u.posts  
> > []
> 
> > u.posts.create!({:title =\> “Foo”, :content =\> “Content of Foo.”})  
> > =\> [#\<Post …\>]
> 
> > u.reload  
> > u.posts.count  
> > 1
> 
> > u.posts.build!({:title =\> “Foo”, :content =\> “Content of Foo.”})  
> > NoMethodError: undefined method ‘build!’ for #Class:...
> 
> > p = u.posts.build({:title =\> “Bar”, :content =\> “Bar content.”})  
> > =\> [#\<Post …]
> 
> > p.save  
> > true
> 
> > u.reload  
> > u.posts.count  
> > 2

Any thoughts, ideas, anything?

Thanks for the help in advance, regards:  
AndrÃ¡s

–  
Tarsoly AndrÃ¡s  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![Tarsoly\_AndrSSSSs](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/57b2e6/32.png) [@Tarsoly\_AndrSSSSs](https://www.ruby-forum.com/u/Tarsoly_AndrSSSSs)\
**Post date:** [September 6, 2007, 11:43am UTC](https://www.ruby-forum.com/t/no-build-on-association/113936/2 "2007-09-06T11:43:26Z")

</div>

hi dude

do u know about :

how to deploy a rails apllication using “Host Gator”

plz help me  
its very urgent.

thats why am posting here.

plz…  
thanks inadvance

---

<div class="post-metadata">

**Author:** ![Tarsoly\_AndrSSSSs](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/57b2e6/32.png) [@Tarsoly\_AndrSSSSs](https://www.ruby-forum.com/u/Tarsoly_AndrSSSSs)\
**Post date:** [September 7, 2007, 5:43am UTC](https://www.ruby-forum.com/t/no-build-on-association/113936/3 "2007-09-07T05:43:49Z")

</div>

I can’t find any other reference to a #build! method, and I’m not  
clear on what it would do. #create! is distinct from #create because  
it will raise an exception on a validation error; since #build on an  
association is analogous to #new on a model class, there’s no  
validation performed.

Where have you used #build! in the past? What did it do, and why can’t  
you use #build?

FWIW, I checked for #build! on association proxies in Rails apps I  
have on hand for both 1.1, 1.2, and edge – and none of them had it.

---

<div class="post-metadata">

**Author:** ![Tarsoly\_AndrSSSSs](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/57b2e6/32.png) [@Tarsoly\_AndrSSSSs](https://www.ruby-forum.com/u/Tarsoly_AndrSSSSs)\
**Post date:** [September 7, 2007, 12:59pm UTC](https://www.ruby-forum.com/t/no-build-on-association/113936/4 "2007-09-07T12:59:43Z")

</div>

Greetings,

On 2007.09.07., at 5:42, removed\_email\_address@domain.invalid wrote:

> I can’t find any other reference to a #build! method, and I’m not  
> clear on what it would do.

Yeah, I was stupid plain and simple. Somehow it’s got into my mind,  
that #build should save and return the object in the collection it’s  
scoped on (what #create does) and I was just frantic because couldn’t  
find any more info on this, obviously.

After looking up my codebase, it was apparent that I never used  
build! before. Sorry for the confusion and thanks for your time  
anyway 🙂

## Have a nice weekend, András

Tarsoly  
Andráremoved\_email\_address@domain.invalid
