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! 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

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

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.

Greetings,

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ás