No build! on association?

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!

Simple scenario:

class User << AR
has_many :posts

class Post
belongs_to :user


u = User.find(1)

u.posts.create!({:title => “Foo”, :content => “Content of Foo.”})
=> [#<Post …>]

1!({:title => “Foo”, :content => “Content of Foo.”})
NoMethodError: undefined method ‘build!’ for #Class:...

p ={:title => “Bar”, :content => “Bar content.”})
=> [#<Post …]


Any thoughts, ideas, anything?

Thanks for the help in advance, regards:

Tarsoly András
[email protected]

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.

thanks inadvance

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.


On 2007.09.07., at 5:42, [email protected] 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 :slight_smile:

Have a nice weekend,

Andrá[email protected]

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs