I have two models, A and B where B blongs_to A and A has_many B. I have a view that does "new" on B and then I call a create method on B which then makes the call @B.create_A(params[:wanted_offer]) All runtime indications seem OK (no error, barfs, etc.) - the logs seem ok too but A does not seem to be getting written in the table. What am I missing? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Thu, Feb 14, 2008 at 8:03 PM, nahabed <roupenn-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > I have two models, A and B where B blongs_to A and A has_many B. > > I have a view that does "new" on B and then I call a create method on > B which then makes the call @B.create_A(params[:wanted_offer])What''s @B here? It would seem to be an instance variable of some object, but it''s wierd to be in uppercase.> All runtime indications seem OK (no error, barfs, etc.) - the logs > seem ok too but A does not seem to be getting written in the table. > > What am I missing?Does A have any validations which might be failing? Remember that the active record create and save methods will just return false if the record fails validation. The create! and save! will raise an exception. If b is an instance of B then you might want to use b.a.create!(params[:wanted_offer]] or at least check the return of create. -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/ --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Sorry for the confusion (B) i didn''t follow the convention. It is an instance variable and what you suggested worked! thanks. On Feb 15, 4:52 am, "Rick DeNatale" <rick.denat...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Thu, Feb 14, 2008 at 8:03 PM,nahabed<roup...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > I have two models, A and B where B blongs_to A and A has_many B. > > > I have a view that does "new" on B and then I call a create method on > > B which then makes the call @B.create_A(params[:wanted_offer]) > > What''s @B here? It would seem to be an instance variable of some > object, but it''s wierd to be in uppercase. > > > All runtime indications seem OK (no error, barfs, etc.) - the logs > > seem ok too but A does not seem to be getting written in the table. > > > What am I missing? > > Does A have any validations which might be failing? Remember that the > active record create and save methods will just return false if the > record fails validation. The create! and save! will raise an > exception. > > If b is an instance of B then you might want to use > b.a.create!(params[:wanted_offer]] > > or at least check the return of create. > > -- > Rick DeNatale > > My blog on Rubyhttp://talklikeaduck.denhaven2.com/--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---