How to insert data into a relational database?

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

On 9/25/06, P.V.Anthony [email protected] wrote:

controller.
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

On this day, 25-September-2006 9:14 PM, Daniel N wrote:

Welcome aboard
Thank you very much for the information. Especially the page number to
the agile rails book.

Once again thank you.

P.V.Anthony