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 tarsolya-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Kumar.1524v-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Sep-06 09:42 UTC
Re: no build! on association?
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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
mboeh-UtljGsy+VVc0aPf6s/0I7w@public.gmane.org
2007-Sep-07 03:42 UTC
Re: no build! on association?
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 Sep 6, 2:35 am, Tarsoly András <tarso...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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 > tarso...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Greetings, On 2007.09.07., at 5:42, mboeh-UtljGsy+VVc0aPf6s/0I7w@public.gmane.org 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ás tarsolya-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---