Hi. Please do bear with me as I am a newbie. I think I understand how to setup the relation using "has_many" with "through". What I need to know is how to insert data into the tables in the controller. For example, I have company details like name, address and country. I also have a category table like audio, video, events and lighting. Once I setup the relations, I need to know how to enter the data into the tables. Since there are two tables and I am using the "has_many" do I have to write two statements. One statement to insert into table one and another one to write to table two. Is there a way to insert data like how it is done for "has_many_belong_to_many" where we can just use "<<"? I have also bought the pdf version of the agile book for rails version 2. If there is a page I should look at, please do advise. Or if there is a website, please do send the link. I really am new at this. Please do not get upset with all these questions. P.V.Anthony --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On 9/25/06, P.V.Anthony <pvantony-rdc5FV7LBygPGFelY5Zqew@public.gmane.org> wrote:> > > Hi. > > Please do bear with me as I am a newbie. > > I think I understand how to setup the relation using "has_many" with > "through". > > What I need to know is how to insert data into the tables in the > controller. > > For example, I have company details like name, address and country. > > I also have a category table like audio, video, events and lighting. > > Once I setup the relations, I need to know how to enter the data into > the tables. > > Since there are two tables and I am using the "has_many" do I have to > write two statements. One statement to insert into table one and another > one to write to table two.There are many differnt ways to specify a new record. An example might be @parent_thing.create( ChildThing.new ) But there are many more listed in great detail in the docs. As long as you''ve run your migration (and setup your db with the migrations) then rails should look after it. Is there a way to insert data like how it is done for> "has_many_belong_to_many" where we can just use "<<"? > > I have also bought the pdf version of the agile book for rails version > 2. If there is a page I should look at, please do advise.has_many starts on page 338. This is a very good look at how it works. The depot application is a very good starting applicaiton also. Or if there is a website, please do send the link.> > I really am new at this. Please do not get upset with all these questions.Welcome aboard P.V.Anthony>--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On this day, 25-September-2006 9:14 PM, Daniel N wrote:> has_many starts on page 338. This is a very good look at how it works. > > The depot application is a very good starting applicaiton also. > > Or if there is a website, please do send the link. > > I really am new at this. Please do not get upset with all these > questions. > > > Welcome aboardThank you very much for the information. Especially the page number to the agile rails book. Once again thank you. P.V.Anthony --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---